module Unparser::Anima::InstanceMethods

Static instance methods for anima infected classes

Public Class Methods

new(attributes) click to toggle source

Initialize an anima infected object

@param [#to_h] attributes

a hash that matches anima defined attributes

@return [undefined]

rubocop:disable Lint/MissingSuper

# File lib/unparser/anima.rb, line 91
def initialize(attributes)
  self.class.anima.initialize_instance(self, attributes)
end

Public Instance Methods

to_h() click to toggle source

Return a hash representation of an anima infected object

@example

anima.to_h # => { :foo => : bar }

@return [Hash]

@api public

# File lib/unparser/anima.rb, line 104
def to_h
  self.class.anima.attributes_hash(self)
end
with(attributes) click to toggle source

Return updated instance

@example

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

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

@param [Hash] attributes

@return [Anima]

@api public

# File lib/unparser/anima.rb, line 125
def with(attributes)
  self.class.new(to_h.update(attributes))
end