Class: ApiBlueprint::Builder
- Defined in:
- lib/api-blueprint/builder.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
writeonly
Sets the attribute body.
Instance Method Summary collapse
Methods inherited from Struct
Instance Attribute Details
#body=(value) ⇒ Object (writeonly)
Sets the attribute body
10 11 12 |
# File 'lib/api-blueprint/builder.rb', line 10 def body=(value) @body = value end |
Instance Method Details
#build ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/api-blueprint/builder.rb', line 12 def build if body.is_a? Array body.collect { |item| build_item prepare_item(item) } else build_item prepare_item(body) end end |
#build_item(item) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/api-blueprint/builder.rb', line 29 def build_item(item) if creates.present? creates.new item else raise BuilderError, "To build an object, you must set #creates" end end |
#prepare_item(item) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/api-blueprint/builder.rb', line 20 def prepare_item(item) = { response_headers: headers, response_status: status } .merge KeyReplacer.replace(item.deep_symbolize_keys, replacements) end |