Module: Redis::Actions::Updating

Defined in:
lib/redis/actions/updating.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



2
3
4
5
6
7
# File 'lib/redis/actions/updating.rb', line 2

def self.included(base)
  base.class_eval do
    base.define_model_callbacks :update
    around_save :update_if_not_new
  end
end

Instance Method Details

#update_if_not_newObject



9
10
11
12
13
14
15
16
17
# File 'lib/redis/actions/updating.rb', line 9

def update_if_not_new
  if new_record?
    yield
  else
    run_callbacks(:update) do
      yield
    end
  end
end