module Gearhead::Extensions::Actions

Public Class Methods

included(klass) click to toggle source
# File lib/gearhead/extensions/actions.rb, line 4
def self.included(klass)
  klass.define_gear_setting :enabled_actions, Gearhead.config.actions.map(&:to_sym)
end

Public Instance Methods

action_enabled?(action) click to toggle source
# File lib/gearhead/extensions/actions.rb, line 23
def action_enabled?(action)
  @_gear_enabled_actions.include?(action)
end
actions(*args) click to toggle source
# File lib/gearhead/extensions/actions.rb, line 12
def actions(*args)
  options = args.extract_options!
  @_gear_enabled_actions = if options[:except]
                             @_gear_enabled_actions - options[:except].map(&:to_sym)
                           elsif options[:only]
                             options[:only].map(&:to_sym)
                           else
                             args.map(&:to_sym)
                           end
end
disable_actions(*actions) click to toggle source
# File lib/gearhead/extensions/actions.rb, line 8
def disable_actions(*actions)
  @_gear_enabled_actions -= actions.map(&:to_sym)
end