class HaveAPI::Authentication::Token::ActionConfig
Public Class Methods
Source
# File lib/haveapi/authentication/token/action_config.rb, line 8 def initialize(block, opts = {}) @block = block @opts = with_defaults(opts) update(block) end
@param block [Proc] @param opts [Hash] @option opts [Boolean] :input @option opts [Boolean] :handle
Public Instance Methods
Source
# File lib/haveapi/authentication/token/action_config.rb, line 32 def handle(&block) if block && check!(:handle) @handle = block else @handle end end
Handle the action @yieldparam request [ActionRequest] @yieldparam result [ActionResult] @yieldreturn [ActionResult]
Source
# File lib/haveapi/authentication/token/action_config.rb, line 20 def input(&block) if block && check!(:input) @input = block else @input end end
Configure input parameters in the context of {HaveAPI::Params}
Source
# File lib/haveapi/authentication/token/action_config.rb, line 15 def update(block) instance_exec(&block) end
@param block [Proc]
Private Instance Methods
Source
# File lib/haveapi/authentication/token/action_config.rb, line 42 def check!(name) raise "#{name} cannot be configured" unless @opts[name] true end
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