Sha256: 04286f8896f351298d2c017ab684c3b3538f99f909a8e995aa3fea417fa8f677
Contents?: true
Size: 1.14 KB
Versions: 3
Compression:
Stored size: 1.14 KB
Contents
# xrubocop:disable all # xfrozen_string_literal: true 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
act_with_flags-0.0.7 | lib/act_with_flags/utils.rb |
act_with_flags-0.0.6 | lib/act_with_flags/utils.rb |
act_with_flags-0.0.4 | lib/act_with_flags/utils.rb |