class ResponseState::Service
Public Class Methods
call(*args, &block)
click to toggle source
# File lib/response_state/service.rb, line 12 def self.call(*args, &block) self.new(*args).call(&block) end
response_states(*states)
click to toggle source
# File lib/response_state/service.rb, line 4 def self.response_states(*states) @valid_states = Array(states) end
valid_states()
click to toggle source
# File lib/response_state/service.rb, line 8 def self.valid_states @valid_states || [:success, :failure] end
Public Instance Methods
call(&block)
click to toggle source
# File lib/response_state/service.rb, line 16 def call(&block) fail NotImplementedError, "A ResponseState::Service should implement the call method.\nThe call method should perform the relevant work of the service and yield a ResponseState::Response object.\n" end
send_state(state, message=nil, context=nil)
click to toggle source
# File lib/response_state/service.rb, line 20 def send_state(state, message=nil, context=nil) ResponseState::Response.new(state, message, context, self.class.valid_states) end