Module: Hashing
- Defined in:
- lib/hashing.rb,
lib/hashing/ivar.rb,
lib/hashing/hasher.rb,
lib/hashing/macros.rb,
lib/hashing/version.rb,
lib/hashing/ivar_collection.rb,
lib/hashing/unconfigured_ivar_error.rb
Overview
Inject the public api into the host class, and it’s instances. By “public api” we understand the class methods
-
Macros#hasherize
And the instance method:
When ‘Hashing` is included, the host class will gain the `.from_hash({})` method and the `#to_h` instance method. Another method that will be added is the private class method `.hasherize` will be added so you can indicate what ivars do you want in your sarialized objects.
Defined Under Namespace
Modules: Macros Classes: Hasher, Ivar, IvarCollection, UnconfiguredIvarError
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
Instance Method Summary collapse
-
#to_h ⇒ Object
The ‘Hash` returned by `#to_h` will be formed by keys based on the ivars names passed to `hasherize` method.
Class Method Details
.included(client_class) ⇒ Object
34 35 36 |
# File 'lib/hashing.rb', line 34 def self.included(client_class) client_class.extend Macros end |
Instance Method Details
#to_h ⇒ Object
The ‘Hash` returned by `#to_h` will be formed by keys based on the ivars names passed to `hasherize` method.
46 47 48 |
# File 'lib/hashing.rb', line 46 def to_h self.class.__hasher.to_h self end |