Class: Gizmo::Make
- Inherits:
-
BaseOperation
- Object
- BaseOperation
- Gizmo::Make
- Defined in:
- lib/gizmo/make.rb
Instance Attribute Summary
Attributes inherited from BaseOperation
Instance Method Summary collapse
-
#call(criteria, attrs, location_proc = nil) ⇒ Gizmo::Response
Make a single item using the provided criteria.
- #default_status ⇒ Object
Methods inherited from BaseOperation
#create_response, #initialize, #set_response_headers
Constructor Details
This class inherits a constructor from Gizmo::BaseOperation
Instance Method Details
#call(criteria, attrs, location_proc = nil) ⇒ Gizmo::Response
Make a single item using the provided criteria.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gizmo/make.rb', line 13 def call(criteria, attrs, location_proc=nil) response = create_response item = criteria.create!(attrs) response.data = item if context.gizmo.respond_to?(:url_for) if location_proc.nil? url = context.gizmo.url_for item else url = location_proc.call(item.id) end response.header :Location, url unless url.nil? end response end |
#default_status ⇒ Object
31 32 33 |
# File 'lib/gizmo/make.rb', line 31 def default_status 201 end |