Sha256: 1e043dc154e4810400a3cc0ff6c9ec238840b92c44ef100e22c55b9e9549103f
Contents?: true
Size: 992 Bytes
Versions: 40
Compression:
Stored size: 992 Bytes
Contents
class ActiveScaffold::DataStructures::Actions include Enumerable def initialize(*args) @set = [] add(*args) end def exclude(*args) args.collect!(&:to_sym) # symbolize the args @set.reject! { |m| args.include? m } # reject all actions specified end def add(*args) args.each { |arg| @set << arg.to_sym unless @set.include? arg.to_sym } end alias << add def each @set.each { |item| yield item } end def include?(val) val.is_a?(Symbol) ? super : @set.any? { |item| item.to_s == val.to_s } 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. def swap(one, two) if include? one exclude one add two else exclude two add one end end protected # called during clone or dup. makes the clone/dup deeper. def initialize_copy(from) @set = from.instance_variable_get('@set').clone end end
Version data entries
40 entries across 40 versions & 1 rubygems