Class: DuckRecord::Reflection::AbstractReflection
- Inherits:
-
Object
- Object
- DuckRecord::Reflection::AbstractReflection
- Defined in:
- lib/duck_record/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.
- #check_validity! ⇒ Object
-
#class_name ⇒ Object
Returns the class name for the macro.
Instance Method Details
#alias_candidate(name) ⇒ Object
142 143 144 |
# File 'lib/duck_record/reflection.rb', line 142 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.
126 127 128 |
# File 'lib/duck_record/reflection.rb', line 126 def build_association(attributes, &block) klass.new(attributes, &block) end |
#check_validity! ⇒ Object
138 139 140 |
# File 'lib/duck_record/reflection.rb', line 138 def check_validity! true end |
#class_name ⇒ Object
Returns the class name for the macro.
composed_of :balance, class_name: 'Money'
returns 'Money'
has_many :clients
returns 'Client'
134 135 136 |
# File 'lib/duck_record/reflection.rb', line 134 def class_name @class_name ||= ([:class_name] || derive_class_name).to_s end |