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.



18
19
20
# File 'lib/active_resource/associations/builder/association.rb', line 18

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

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



12
13
14
# File 'lib/active_resource/associations/builder/association.rb', line 12

def klass
  @klass
end

#modelObject (readonly)

Returns the value of attribute model.



12
13
14
# File 'lib/active_resource/associations/builder/association.rb', line 12

def model
  @model
end

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/active_resource/associations/builder/association.rb', line 12

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



12
13
14
# File 'lib/active_resource/associations/builder/association.rb', line 12

def options
  @options
end

Class Method Details

.build(model, name, options) ⇒ Object



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

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

Instance Method Details

#buildObject



22
23
24
25
# File 'lib/active_resource/associations/builder/association.rb', line 22

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