Module: Shared::OriginRelationship

Extended by:
ActiveSupport::Concern
Included in:
CollectionObject
Defined in:
app/models/concerns/shared/origin_relationship.rb

Overview

Shared code for extending data classes with an OriginRelationship

Instructions on how to use this concern:
  1) Include this concern in the table that can have origin relationship target tables
  2) Call "is_origin_for" with valid target tables
    ex is_origin_for :collection_objects, collecting_events etc

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary (collapse)

Instance Method Details

- (Object) reject_origin_relationships(attributes) (private)



38
39
40
41
42
43
44
# File 'app/models/concerns/shared/origin_relationship.rb', line 38

def reject_origin_relationships(attributes)
  if !defined? valid_origin_target_tables
    raise NoMethodError.new('"is_origin_for" must be called with valid target tables in the class including the "OriginRelationship" module!')
  end

  attributes['new_object'].blank? || !valid_origin_target_tables.include?(attributes['new_object'].class.table_name.to_sym)
end