Class: ActiveType::NestedAttributes::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/active_type/nested_attributes/builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(owner, mod) ⇒ Builder

Returns a new instance of Builder.



10
11
12
13
# File 'lib/active_type/nested_attributes/builder.rb', line 10

def initialize(owner, mod)
  @owner = owner
  @module = mod
end

Instance Method Details

#build(name, one_or_many, options) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/active_type/nested_attributes/builder.rb', line 15

def build(name, one_or_many, options)
  add_attribute(name, options.slice(:default))
  association = build_association(name, one_or_many == :one, options.except(:default))
  add_writer_method(name, association)
  add_autosave(name, association)
  add_validation(name, association)
end