Module: Shared::OriginRelationship::ClassMethods

Defined in:
app/models/concerns/shared/origin_relationship.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) is_origin_for(*args)



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/models/concerns/shared/origin_relationship.rb', line 19

def is_origin_for(*args)
  if args.length == 0
    raise ArgumentError.new("is_origin_for must have an array full of valid target tables supplied!")
  end
  
  # Returns the valid target tables in symbol form
  define_method :valid_origin_target_tables do
    args
  end

  # Returns the valid target tables in class form
  define_singleton_method :valid_origin_target_classes do
    args.collect{ |table_symbol| table_symbol.to_s.classify.constantize }
  end
end