Sha256: 61ff9fac908b3c909df1c084414977899aaa69f4ff0add6a6b28e59406f7e5e0
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
class ActWithFlags::Admin def add_accessor(name, pos) #p "** act_with_flags: add_accessor '#{name} @ #{pos}'" accessor = name.to_sym validate_accessor accessor, "#{accessor}?", "#{accessor}=" add accessor, pos mask = mask(accessor) origin = self.origin add_accessors(origin, accessor, mask) end def add_mask_et_all(origin) model.class_eval %( def flags_mask(*names) self.class.act_with_flags.mask(*names) end def flags_any?(*names) mask = self.class.act_with_flags.mask(*names) !( self.#{origin} & mask ).zero? end def flags_all?(*names) mask = self.class.act_with_flags.mask(*names) ( self.#{origin} & mask ) == mask end def flags_none?(*names) mask = self.class.act_with_flags.mask(*names) ( self.#{origin} & mask ).zero? end ) end def delete_mask_et_all my_undef :flags_mask, :flags_any?, :flags_all?, :flags_none? end def reset delete_mask_et_all names.each { |name| remove_accessor name } self.reset_model model end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
act_with_flags-0.1.0 | lib/act_with_flags/utils.rb |