Class: ApiBlueprint::Blueprint
- Defined in:
- lib/api-blueprint/blueprint.rb
Instance Method Summary collapse
Instance Method Details
#all_request_options(options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/api-blueprint/blueprint.rb', line 14 def ( = {}) { http_method: http_method, url: url, headers: headers.merge(.fetch(:headers, {})), params: params.merge(.fetch(:params, {})), body: body.merge(.fetch(:body, {})) } end |
#run(options = {}, runner = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/api-blueprint/blueprint.rb', line 24 def run( = {}, runner = nil) if .delete :validate result = build from: [:body] return result.errors if result.invalid? end response = call_api () if creates.present? created = build from: response.body, headers: response.headers, status: response.status else created = response end after_build.present? ? after_build.call(runner, created) : created end |