class ActiveScaffold::DataStructures::Actions
Public Class Methods
new(*args)
click to toggle source
# File lib/active_scaffold/data_structures/actions.rb, line 4 def initialize(*args) @set = [] self.add *args end
Public Instance Methods
add(*args)
click to toggle source
# File 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
Also aliased as: <<
each() { |item| ... }
click to toggle source
# File lib/active_scaffold/data_structures/actions.rb, line 19 def each @set.each {|item| yield item} end
exclude(*args)
click to toggle source
# File 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)
click to toggle source
Calls superclass method
# File lib/active_scaffold/data_structures/actions.rb, line 23 def include?(val) super val.to_sym end
swap(one, two)
click to toggle source
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.
# File 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
Protected Instance Methods
initialize_copy(from)
click to toggle source
called during clone or dup. makes the clone/dup deeper.
# File lib/active_scaffold/data_structures/actions.rb, line 42 def initialize_copy(from) @set = from.instance_variable_get('@set').clone end