lib/banditmask/banditry.rb in banditmask-0.2.0 vs lib/banditmask/banditry.rb in banditmask-0.2.1

- old
+ new

@@ -1,13 +1,7 @@ -require 'forwardable' - class BanditMask module Banditry - def self.extended(cls) # :nodoc: - cls.extend Forwardable - end - ## # Creates wrapper methods for reading and writing the bitmask stored in # +attribute+ using the class +with+. +with+ defaults to BanditMask, but # you can (and probably) should define your own class descending from # +BanditMask+ to fill this role. The name of the accessor methods will be @@ -50,10 +44,12 @@ define_method :"#{wrapper}=" do |bits| mask = bits.reduce(cls.new) { |mask, bit| mask << bit } send :"#{attribute}=", Integer(mask) end - def_delegator wrapper, :include?, :has? + define_method :has? do |*bits| + cls.new(send(attribute)).include? *bits + end end end end end