Class: ActiveEntity::Reflection::AbstractEmbeddedReflection

Inherits:
AbstractReflection show all
Defined in:
lib/active_entity/reflection.rb

Overview

:nodoc:

Direct Known Subclasses

MacroEmbeddedReflection

Instance Method Summary collapse

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_nameObject

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 ||= (options[:class_name] || derive_class_name).to_s
end

#embedded?Boolean

Returns:

  • (Boolean)


153
154
155
# File 'lib/active_entity/reflection.rb', line 153

def embedded?
  true
end

#inverse_ofObject



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

Returns:

  • (Boolean)


157
158
159
# File 'lib/active_entity/reflection.rb', line 157

def through_reflection?
  false
end