Class: ActiveScaffold::DataStructures::Actions

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/actions.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Actions

Returns a new instance of Actions.



4
5
6
7
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/actions.rb', line 4

def initialize(*args)
  @set = []
  self.add *args
end

Instance Method Details

#add(*args) ⇒ Object Also known as: <<



14
15
16
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/actions.rb', line 14

def add(*args)
  args.each { |arg| @set << arg.to_sym unless @set.include? arg.to_sym }
end

#eachObject



19
20
21
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/actions.rb', line 19

def each
  @set.each {|item| yield item}
end

#exclude(*args) ⇒ Object



9
10
11
12
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/actions.rb', line 9

def exclude(*args)
  args.collect! { |a| a.to_sym } # symbolize the args
  @set.reject! { |m| args.include? m } # reject all actions specified
end

#include?(val) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/actions.rb', line 23

def include?(val)
  super val.to_sym
end

#swap(one, two) ⇒ Object

swaps one element in the list with the other. accepts arguments in any order. it just figures out which one is in the list and which one is not.



29
30
31
32
33
34
35
36
37
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/actions.rb', line 29

def swap(one, two)
  if include? one
    exclude one
    add two
  else
    exclude two
    add one
  end
end