Class: ActiveFedora::Reflection::AbstractReflection
- Inherits:
-
Object
- Object
- ActiveFedora::Reflection::AbstractReflection
- 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
Instance Method Summary collapse
- #alias_candidate(name) ⇒ Object
-
#build_association(attributes, &block) ⇒ Object
Returns a new, unsaved instance of the associated class.
- #chain ⇒ Object
- #check_validity_of_inverse! ⇒ Object
-
#class_name ⇒ Object
Returns the class name for the macro.
- #constraints ⇒ Object
- #inverse_of ⇒ Object
-
#through_reflection? ⇒ Boolean
:nodoc:.
Instance Method Details
#alias_candidate(name) ⇒ Object
193 194 195 |
# File 'lib/active_fedora/reflection.rb', line 193 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 |
#chain ⇒ Object
197 198 199 |
# File 'lib/active_fedora/reflection.rb', line 197 def chain collect_join_chain end |
#check_validity_of_inverse! ⇒ Object
185 186 187 188 189 190 191 |
# File 'lib/active_fedora/reflection.rb', line 185 def check_validity_of_inverse! unless polymorphic? if has_inverse? && inverse_of.nil? raise InverseOfAssociationNotFoundError, self end 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_fedora/reflection.rb', line 171 def class_name @class_name ||= ([:class_name] || derive_class_name).to_s end |
#constraints ⇒ Object
175 176 177 |
# File 'lib/active_fedora/reflection.rb', line 175 def constraints scope_chain.flatten end |
#inverse_of ⇒ Object
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:
157 158 159 |
# File 'lib/active_fedora/reflection.rb', line 157 def through_reflection? false end |