class Gizmo::Make
Public Instance Methods
call(criteria, attrs, location_proc=nil)
click to toggle source
Make
a single item using the provided criteria.
@param [Mongoid::Criteria] criteria the criteria to use for making a single item @param [Hash] attrs the attributes used to make a new instance @param [Proc] location_proc a Proc that will be invoked with the ID of the newly
created item, defaults to nil.
@return [Gizmo::Response]
# 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()
click to toggle source
# File lib/gizmo/make.rb, line 31 def default_status 201 end