Class: ActiveType::NestedAttributes::Builder
- Inherits:
-
Object
- Object
- ActiveType::NestedAttributes::Builder
- Defined in:
- lib/active_type/nested_attributes/builder.rb
Instance Method Summary collapse
- #build(name, one_or_many, options) ⇒ Object
-
#initialize(owner, mod) ⇒ Builder
constructor
A new instance of Builder.
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, ) add_attribute(name, .slice(:default)) association = build_association(name, one_or_many == :one, .except(:default)) add_writer_method(name, association) add_autosave(name, association) add_validation(name, association) end |