Module: Bitfields::InstanceMethods

Defined in:
lib/bitfields.rb

Instance Method Summary collapse

Instance Method Details

#bitfield_changesObject


170
171
172
173
174
175
# File 'lib/bitfields.rb', line 170

def bitfield_changes
  self.class.bitfields.values.flat_map(&:keys).each_with_object({}) do |bit, changes|
    old, current = bitfield_value_was(bit), bitfield_value(bit)
    changes[bit.to_s] = [old, current] unless old == current
  end
end

#bitfield_values(column) ⇒ Object


166
167
168
# File 'lib/bitfields.rb', line 166

def bitfield_values(column)
  Hash[self.class.bitfields[column.to_sym].map{|bit_name, _| [bit_name, bitfield_value(bit_name)]}]
end