Class: ActiveResource::Reflection::AssociationReflection

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(macro, name, options) ⇒ AssociationReflection

Returns a new instance of AssociationReflection.



30
31
32
# File 'lib/active_resource/reflection.rb', line 30

def initialize(macro, name, options)
  @macro, @name, @options = macro, name, options
end

Instance Attribute Details

#macroObject (readonly)

Returns the macro type.

has_many :clients returns :has_many



42
43
44
# File 'lib/active_resource/reflection.rb', line 42

def macro
  @macro
end

#nameObject (readonly)

Returns the name of the macro.

has_many :clients returns :clients



37
38
39
# File 'lib/active_resource/reflection.rb', line 37

def name
  @name
end

#optionsObject (readonly)

Returns the hash of options used for the macro.

has_many :clients returns {}



47
48
49
# File 'lib/active_resource/reflection.rb', line 47

def options
  @options
end

Instance Method Details

#class_nameObject

Returns the class name for the macro.

has_many :clients returns 'Client'



59
60
61
# File 'lib/active_resource/reflection.rb', line 59

def class_name
  @class_name ||= derive_class_name
end

#foreign_keyObject

Returns the foreign_key for the macro.



64
65
66
# File 'lib/active_resource/reflection.rb', line 64

def foreign_key
  @foreign_key ||= derive_foreign_key
end

#klassObject

Returns the class for the macro.

has_many :clients returns the Client class



52
53
54
# File 'lib/active_resource/reflection.rb', line 52

def klass
  @klass ||= class_name.constantize
end