Module: Hashing::Macros

Defined in:
lib/hashing/macros.rb

Overview

Define the class methods that should be available in a ‘hasherized ®’ class (a class that include Hashing).

Since:

  • 0.0.1

Instance Method Summary collapse

Instance Method Details

#__hasherObject

Provides the entry point to the object that has the actual logic of serialization/unserialization for Hashing instances. The ideia here is to not polute the host class with a bunch of methods included by the Hashing. Instead, we just inject the api method #hasherize, #from_hash and the internally used #__hasher method.

Since:

  • 0.0.1



34
35
36
# File 'lib/hashing/macros.rb', line 34

def __hasher
  @__hasher ||= Hasher.new self
end

#from_hash(hash) ⇒ Object

Receives a ‘Hash` and uses the strategy configured by `.loading` to (re)create an instance of the ’hasherized ®‘ class.

Parameters:

  • hash (Hash)

    in a valid form defined by ‘.hasherize`

Returns:

  • new object

Since:

  • 0.0.1



25
26
27
# File 'lib/hashing/macros.rb', line 25

def from_hash(hash)
  __hasher.load hash
end