Module: Gearhead::Extensions::Actions

Included in:
Gear
Defined in:
lib/gearhead/extensions/actions.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



4
5
6
# 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

Instance Method Details

#action_enabled?(action) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/gearhead/extensions/actions.rb', line 23

def action_enabled?(action)
  @_gear_enabled_actions.include?(action)
end

#actions(*args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# 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) ⇒ Object



8
9
10
# File 'lib/gearhead/extensions/actions.rb', line 8

def disable_actions(*actions)
  @_gear_enabled_actions -= actions.map(&:to_sym)
end