Class: ActiveFedora::Reflection::ClassMethods::AssociationReflection
- Inherits:
-
MacroReflection
- Object
- MacroReflection
- ActiveFedora::Reflection::ClassMethods::AssociationReflection
- Defined in:
- lib/active_fedora/reflection.rb
Overview
Holds all the meta-data about an association as it was specified in the Active Record class.
Instance Attribute Summary
Attributes inherited from MacroReflection
Instance Method Summary collapse
-
#create_association(*options) ⇒ Object
Creates a new instance of the associated class, and immediately saves it with ActiveRecord::Base#save.
-
#initialize(macro, name, options, active_record) ⇒ AssociationReflection
constructor
:nodoc:.
- #primary_key_name ⇒ Object
Methods inherited from MacroReflection
#build_association, #class_name, #collection?, #klass
Constructor Details
#initialize(macro, name, options, active_record) ⇒ AssociationReflection
:nodoc:
129 130 131 132 |
# File 'lib/active_fedora/reflection.rb', line 129 def initialize(macro, name, , active_record) super @collection = [:has_many, :has_and_belongs_to_many].include?(macro) end |
Instance Method Details
#create_association(*options) ⇒ Object
Creates a new instance of the associated class, and immediately saves it with ActiveRecord::Base#save. options
will be passed to the class’s creation method. Returns the newly created object.
142 143 144 |
# File 'lib/active_fedora/reflection.rb', line 142 def create_association(*) klass.create(*) end |
#primary_key_name ⇒ Object
134 135 136 |
# File 'lib/active_fedora/reflection.rb', line 134 def primary_key_name @primary_key_name ||= [:foreign_key] || derive_primary_key_name end |