Netzke::Actions::ClassMethods

Public Instance Methods

action(name, config = {}, █) click to toggle source
# File lib/netzke/actions.rb, line 42
def action(name, config = {}, &block)
  register_action(name)
  config[:name] = name.to_s
  method_name = ACTION_METHOD_NAME % name
  if block_given?
    define_method(method_name, &block)
  else
    if superclass.instance_methods.map(&:to_s).include?(method_name)
      define_method(method_name) do
        super().merge(config)
      end
    else
      define_method(method_name) do
        config
      end
    end
  end
end
register_action(name) click to toggle source

Register an action

# File lib/netzke/actions.rb, line 63
def register_action(name)
  current_actions = read_inheritable_attribute(:actions) || []
  current_actions << name
  write_inheritable_attribute(:actions, current_actions.uniq)
end
registered_actions() click to toggle source

Returns registered actions

# File lib/netzke/actions.rb, line 70
def registered_actions
  read_inheritable_attribute(:actions) || []
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.