class HaveAPI::Authentication::Token::ActionConfig
Public Class Methods
new(block, opts = {})
click to toggle source
@param block [Proc] @param opts [Hash] @option opts [Boolean] :input @option opts [Boolean] :handle
# File lib/haveapi/authentication/token/action_config.rb, line 8 def initialize(block, opts = {}) @block = block @opts = with_defaults(opts) update(block) end
Public Instance Methods
handle(&block)
click to toggle source
Handle the action @yieldparam request [ActionRequest] @yieldparam result [ActionResult] @yieldreturn [ActionResult]
# File lib/haveapi/authentication/token/action_config.rb, line 32 def handle(&block) if block && check!(:handle) @handle = block else @handle end end
input(&block)
click to toggle source
Configure input parameters in the context of {HaveAPI::Params}
# File lib/haveapi/authentication/token/action_config.rb, line 20 def input(&block) if block && check!(:input) @input = block else @input end end
update(block)
click to toggle source
@param block [Proc]
# File lib/haveapi/authentication/token/action_config.rb, line 15 def update(block) instance_exec(&block) end
Private Instance Methods
check!(name)
click to toggle source
# File lib/haveapi/authentication/token/action_config.rb, line 42 def check!(name) raise "#{name} cannot be configured" unless @opts[name] true end
with_defaults(opts)
click to toggle source
# File lib/haveapi/authentication/token/action_config.rb, line 48 def with_defaults(opts) %i[input handle].to_h do |v| [v, opts.has_key?(v) ? opts[v] : true] end end