Class: ActiveFedora::Reflection::AbstractReflection

Inherits:
Object
  • Object
show all
Defined in:
lib/active_fedora/reflection.rb

Overview

Holds all the methods that are shared between MacroReflection and ThroughReflection.

AbstractReflection
  MacroReflection
    AggregateReflection
    AssociationReflection
      HasManyReflection
      HasOneReflection
      BelongsToReflection
      HasAndBelongsToManyReflection
  ThroughReflection
    PolymorphicReflection
      RuntimeReflection

Direct Known Subclasses

MacroReflection

Instance Method Summary collapse

Instance Method Details

#alias_candidate(name) ⇒ Object



190
191
192
# File 'lib/active_fedora/reflection.rb', line 190

def alias_candidate(name)
  "#{plural_name}_#{name}"
end

#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_fedora/reflection.rb', line 163

def build_association(attributes, &block)
  klass.new(attributes, &block)
end

#chainObject



194
195
196
# File 'lib/active_fedora/reflection.rb', line 194

def chain
  collect_join_chain
end

#check_validity_of_inverse!Object



185
186
187
188
# File 'lib/active_fedora/reflection.rb', line 185

def check_validity_of_inverse!
  return if polymorphic?
  raise InverseOfAssociationNotFoundError, self if has_inverse? && inverse_of.nil?
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_fedora/reflection.rb', line 171

def class_name
  @class_name ||= (options[:class_name] || derive_class_name).to_s
end

#constraintsObject



175
176
177
# File 'lib/active_fedora/reflection.rb', line 175

def constraints
  scope_chain.flatten
end

#inverse_ofObject



179
180
181
182
183
# File 'lib/active_fedora/reflection.rb', line 179

def inverse_of
  return unless inverse_name

  @inverse_of ||= klass._reflect_on_association inverse_name
end

#through_reflection?Boolean

:nodoc:

Returns:

  • (Boolean)


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

def through_reflection?
  false
end