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



132
133
134
# File 'lib/duck_record/reflection.rb', line 132

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.



116
117
118
# File 'lib/duck_record/reflection.rb', line 116

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

#check_validity!Object



128
129
130
# File 'lib/duck_record/reflection.rb', line 128

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'



124
125
126
# File 'lib/duck_record/reflection.rb', line 124

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