Class: Spyke::Associations::Builder

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

Instance Method Summary collapse

Constructor Details

#initialize(parent_class, name, type, options = {}) ⇒ Builder

Returns a new instance of Builder.



4
5
6
# File 'lib/spyke/associations/builder.rb', line 4

def initialize(parent_class, name, type, options = {})
  @parent_class, @name, @type, @options = parent_class, name, type, options
end

Instance Method Details

#build(parent) ⇒ Object



8
9
10
# File 'lib/spyke/associations/builder.rb', line 8

def build(parent)
  @type.new(klass, parent, @name, @options)
end

#klassObject



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

def klass
  @klass ||= custom_class || compute_class(@name)
end