Class: DuckRecord::Reflection::AbstractReflection

Inherits:
Object
  • Object
show all
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

MacroReflection

Instance Method Summary collapse

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_nameObject

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