class ApiMaker::IndividualCommand
Attributes
args[R]
command[R]
id[R]
Public Class Methods
new(id:, args:, collection:, command:, primary_key: nil, response:)
click to toggle source
# File lib/api_maker/individual_command.rb, line 4 def initialize(id:, args:, collection:, command:, primary_key: nil, response:) @id = id @args = args @collection = collection @command = command @primary_key = primary_key @response = response end
Public Instance Methods
error(data = nil)
click to toggle source
# File lib/api_maker/individual_command.rb, line 13 def error(data = nil) @response.error_for_command(@id, data) end
fail(data = nil)
click to toggle source
# File lib/api_maker/individual_command.rb, line 17 def fail(data = nil) @response.fail_for_command(@id, data) end
model()
click to toggle source
# File lib/api_maker/individual_command.rb, line 21 def model raise "Collection wasn't set" unless @collection @model ||= @collection.find { |model| model.id.to_s == @primary_key.to_s } raise "Couldn't find model by that ID: #{@primary_key}" unless @model @model end
model_id()
click to toggle source
# File lib/api_maker/individual_command.rb, line 30 def model_id @primary_key end
result(data = nil)
click to toggle source
# File lib/api_maker/individual_command.rb, line 34 def result(data = nil) @response.result_for_command(@id, ApiMaker::ResultParser.parse(data, controller: @response.controller)) end