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


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

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

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass


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

def klass
  @klass
end

#modelObject (readonly)

Returns the value of attribute model


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

def model
  @model
end

#nameObject (readonly)

Returns the value of attribute name


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

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options


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

def options
  @options
end

Class Method Details

.build(model, name, options) ⇒ Object


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

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

Instance Method Details

#buildObject


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

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