Class: DatastaxRails::Associations::Builder::Association

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

Overview

:nodoc:

Direct Known Subclasses

CollectionAssociation, SingularAssociation

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


15
16
17
# File 'lib/datastax_rails/associations/builder/association.rb', line 15

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

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model


9
10
11
# File 'lib/datastax_rails/associations/builder/association.rb', line 9

def model
  @model
end

#nameObject (readonly)

Returns the value of attribute name


9
10
11
# File 'lib/datastax_rails/associations/builder/association.rb', line 9

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options


9
10
11
# File 'lib/datastax_rails/associations/builder/association.rb', line 9

def options
  @options
end

#reflectionObject (readonly)

Returns the value of attribute reflection


9
10
11
# File 'lib/datastax_rails/associations/builder/association.rb', line 9

def reflection
  @reflection
end

Class Method Details

.build(model, name, options) ⇒ Object


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

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

Instance Method Details

#buildObject


21
22
23
24
25
26
27
# File 'lib/datastax_rails/associations/builder/association.rb', line 21

def build
  validate_options
  @reflection = model.create_reflection(self.class.macro, name, options, model)
  define_accessors
  super # provides an extension point
  @reflection
end

#mixinObject


29
30
31
# File 'lib/datastax_rails/associations/builder/association.rb', line 29

def mixin
  @model.generated_attribute_methods
end