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).
Instance Method Summary collapse
-
#__hasher ⇒ Object
Provides the entry point to the object that has the actual logic of serialization/unserialization for Hashing instances.
-
#from_hash(hash) ⇒ Object
Receives a ‘Hash` and uses the strategy configured by `.loading` to (re)create an instance of the ’hasherized ®‘ class.
Instance Method Details
#__hasher ⇒ Object
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.
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.
25 26 27 |
# File 'lib/hashing/macros.rb', line 25 def from_hash(hash) __hasher.load hash end |