class ActiveScaffold::DataStructures::Actions
Public Class Methods
Source
# File lib/active_scaffold/data_structures/actions.rb, line 4 def initialize(*args) @set = [] add(*args) end
Public Instance Methods
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: <<
Source
# File lib/active_scaffold/data_structures/actions.rb, line 19 def each(&) @set.each(&) end
Source
# File lib/active_scaffold/data_structures/actions.rb, line 9 def exclude(*args) args.collect!(&:to_sym) # symbolize the args @set.reject! { |m| args.include? m } # reject all actions specified end
Source
# File lib/active_scaffold/data_structures/actions.rb, line 23 def include?(val) val.is_a?(Symbol) ? super : @set.any? { |item| item.to_s == val.to_s } end
Calls superclass method
Source
# 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
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.
Protected Instance Methods
Source
# File lib/active_scaffold/data_structures/actions.rb, line 42 def initialize_copy(from) @set = from.instance_variable_get(:@set).clone end
called during clone or dup. makes the clone/dup deeper.