class ResourceSubscriber::Changes

Public Class Methods

new(changes) click to toggle source
# File lib/resource_subscriber/changes.rb, line 3
def initialize(changes)
  @changes = changes.with_indifferent_access
end

Public Instance Methods

__getobj__() click to toggle source
# File lib/resource_subscriber/changes.rb, line 7
def __getobj__
  @changes
end
was_changed?(attribute_name, to:nil, from:nil) click to toggle source
# File lib/resource_subscriber/changes.rb, line 11
def was_changed?(attribute_name, to:nil, from:nil)
  result = true
  value = self[attribute_name]
  result &&= !!value
  result &&= self.key?(attribute_name)
  result &&= (to == self[attribute_name][1]) if to
  result &&= (from == self[attribute_name][0]) if from
  result
end