Module: BigRecord::BrReflection::ClassMethods

Defined in:
lib/big_record/br_reflection.rb

Overview

Reflection allows you to interrogate Big Record classes and objects about their associations and aggregations. This information can, for example, be used in a form builder that took an Big Record object and created input fields for all of the attributes depending on their type and displayed the associations to other objects.

You can find the interface for the AggregateReflection and AssociationReflection classes in the abstract MacroReflection class.

Instance Method Summary

Instance Method Details

- (Object) create_reflection_big_record(macro, name, options, big_record)



14
15
16
17
18
19
20
21
22
23
# File 'lib/big_record/br_reflection.rb', line 14

def create_reflection_big_record(macro, name, options, big_record)
  case macro
    when :has_many_big_records, :belongs_to_big_record, :belongs_to_many, :has_one_big_record, :has_and_belongs_to_many_big_records
      reflection = BrAssociationReflection.new(macro, name, options, big_record)
    when :composed_of_big_record
      reflection = BrAggregateReflection.new(macro, name, options, big_record)
  end
  write_inheritable_hash :reflections, name => reflection
  reflection
end