Module: ActionHandler::HandlerExtension

Defined in:
lib/action_handler/equip.rb

Instance Method Summary collapse

Instance Method Details

#action_methods(*method_names) ⇒ Object



42
43
44
# File 'lib/action_handler/equip.rb', line 42

def action_methods(*method_names)
  ActionHandler::Config.get(self).action_methods = method_names
end

#arg(name, &block) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/action_handler/equip.rb', line 61

def arg(name, &block)
  unless block_given?
    raise '`arg` requires block. Use `args` to register arguments supplier object'
  end

  ActionHandler::Config.get(self).add_arg(name, &block)
end

#args(*suppliers) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/action_handler/equip.rb', line 46

def args(*suppliers)
  raise '`args` does not accept block. Use `arg` to define custom argument' if block_given?

  config = ActionHandler::Config.get(self)
  suppliers.each do |supplier|
    config.add_args_supplier(supplier)
  end
end

#args_params(*names) ⇒ Object



55
56
57
58
59
# File 'lib/action_handler/equip.rb', line 55

def args_params(*names)
  ActionHandler::Config.get(self).add_args_supplier(
    ActionHandler::Args::Params.new(*names),
  )
end

#as_controller(&block) ⇒ Object



38
39
40
# File 'lib/action_handler/equip.rb', line 38

def as_controller(&block)
  ActionHandler::Config.get(self).as_controller = block
end