Module: RedisModelExtension::Dirty

Extended by:
ActiveSupport::Concern
Defined in:
lib/redis-model-extension/dirty.rb

Overview

Dirty

module for easier detection of changed attributes

if you want it in your model include it after RedisModelExtension, i.e.

class MyModel
  include RedisModelExtension
  include RedisModelExtension::Dirty
end

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#attribute=(name, value) ⇒ Object



20
21
22
23
# File 'lib/redis-model-extension/dirty.rb', line 20

def attribute=(name, value)
  attribute_will_change!(name) unless value == attribute(name)
  super
end

#saveObject



25
26
27
28
29
30
31
# File 'lib/redis-model-extension/dirty.rb', line 25

def save
  if result = super
    @previously_changed = changes
    @changed_attributes.clear
  end
  result
end