Class: ActiveEntity::Reflection::AbstractEmbeddedReflection
- Inherits:
-
AbstractReflection
- Object
- AbstractReflection
- ActiveEntity::Reflection::AbstractEmbeddedReflection
- Defined in:
- lib/active_entity/reflection.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Method Summary collapse
-
#build_association(attributes, &block) ⇒ Object
Returns a new, unsaved instance of the associated class.
- #check_validity_of_inverse! ⇒ Object
-
#class_name ⇒ Object
Returns the class name for the macro.
- #embedded? ⇒ Boolean
- #inverse_of ⇒ Object
- #through_reflection? ⇒ Boolean
Instance Method Details
#build_association(attributes, &block) ⇒ Object
Returns a new, unsaved instance of the associated class. attributes
will be passed to the class’s constructor.
163 164 165 |
# File 'lib/active_entity/reflection.rb', line 163 def build_association(attributes, &block) klass.new(attributes, &block) end |
#check_validity_of_inverse! ⇒ Object
181 182 183 184 185 |
# File 'lib/active_entity/reflection.rb', line 181 def check_validity_of_inverse! if has_inverse? && inverse_of.nil? raise InverseOfAssociationNotFoundError.new(self) end end |
#class_name ⇒ Object
Returns the class name for the macro.
composed_of :balance, class_name: 'Money'
returns 'Money'
has_many :clients
returns 'Client'
171 172 173 |
# File 'lib/active_entity/reflection.rb', line 171 def class_name @class_name ||= ([:class_name] || derive_class_name).to_s end |
#embedded? ⇒ Boolean
153 154 155 |
# File 'lib/active_entity/reflection.rb', line 153 def true end |
#inverse_of ⇒ Object
175 176 177 178 179 |
# File 'lib/active_entity/reflection.rb', line 175 def inverse_of return unless inverse_name @inverse_of ||= klass._reflect_on_association inverse_name end |
#through_reflection? ⇒ Boolean
157 158 159 |
# File 'lib/active_entity/reflection.rb', line 157 def through_reflection? false end |