Class: Hasherize
- Inherits:
-
Module
- Object
- Module
- Hasherize
- Defined in:
- lib/hasherize.rb
Overview
Provides some sugar syntax to declare which ‘ivars` should be used to represent an object as a `Hash`.
It respects all the behavior you will get by including Hashing. In fact, using this constructor is a shortcut to ‘include Hashing`, and call `.hasherize`
Instance Method Summary collapse
-
#included(serializable_class) ⇒ Object
Includes the ‘Hashing` module and calls Hashing.hasherize, repassing the ivar names an the options received in the constructor.
-
#initialize(*ivars_and_options) ⇒ Hasherize
constructor
Stores the ivars and options to be repassed to ‘Hashing.serialize` by the hook #included.
Constructor Details
Instance Method Details
#included(serializable_class) ⇒ Object
Includes the ‘Hashing` module and calls Hashing.hasherize, repassing the ivar names an the options received in the constructor
34 35 36 37 38 39 |
# File 'lib/hasherize.rb', line 34 def included(serializable_class) serializable_class.module_eval do include Hashing end serializable_class.send :hasherize, *@ivars end |