Class: ActiveResource::Associations::Builder::Association

Inherits:
Object
  • Object
show all
Defined in:
lib/active_resource/associations/builder/association.rb

Overview

:nodoc:

Direct Known Subclasses

BelongsTo, HasMany, HasOne

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, name, options) ⇒ Association

Returns a new instance of Association.



20
21
22
# File 'lib/active_resource/associations/builder/association.rb', line 20

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

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



14
15
16
# File 'lib/active_resource/associations/builder/association.rb', line 14

def klass
  @klass
end

#modelObject (readonly)

Returns the value of attribute model.



14
15
16
# File 'lib/active_resource/associations/builder/association.rb', line 14

def model
  @model
end

#nameObject (readonly)

Returns the value of attribute name.



14
15
16
# File 'lib/active_resource/associations/builder/association.rb', line 14

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



14
15
16
# File 'lib/active_resource/associations/builder/association.rb', line 14

def options
  @options
end

Class Method Details

.build(model, name, options) ⇒ Object



16
17
18
# File 'lib/active_resource/associations/builder/association.rb', line 16

def self.build(model, name, options)
  new(model, name, options).build
end

Instance Method Details

#buildObject



24
25
26
27
# File 'lib/active_resource/associations/builder/association.rb', line 24

def build
  validate_options
  reflection = model.create_reflection(self.class.macro, name, options)
end