Class: InstantApi::Model::Builder
- Inherits:
-
Object
- Object
- InstantApi::Model::Builder
- Defined in:
- lib/instant_api/model/builder.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(params, klass, root = false) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
4 5 6 |
# File 'lib/instant_api/model/builder.rb', line 4 def klass @klass end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
4 5 6 |
# File 'lib/instant_api/model/builder.rb', line 4 def params @params end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
4 5 6 |
# File 'lib/instant_api/model/builder.rb', line 4 def root @root end |
Instance Method Details
#build ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/instant_api/model/builder.rb', line 12 def build record = nil klass.transaction do record = klass.create(params_primitives).tap do |object| create_nested_records(object) end raise ActiveRecord::Rollback if rollback?(record) end record end |