Module: Anima::Update

Defined in:
lib/anima/update.rb

Overview

Module for mixin in update functionallity to anima infected clases

Instance Method Summary collapse

Instance Method Details

#update(attributes) ⇒ Anima

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return updated instance

Examples:

klass = Class.new do
  include Anima.new(:foo, :bar), Anima::Update
end

foo = klass.new(:foo => 1, :bar => 2)
updated = foo.update(:foo => 3)
updated.foo # => 3
updated.bar # => 2

Parameters:

  • attributes (Hash)

Returns:



23
24
25
26
# File 'lib/anima/update.rb', line 23

def update(attributes)
  klass = self.class
  klass.new(klass.attributes_hash(self).merge(attributes))
end