Class: HashMapper
- Inherits:
-
Object
- Object
- HashMapper
- Defined in:
- lib/hash-mapper.rb,
lib/hash-mapper/dsl.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Method Summary collapse
-
#initialize(opts = [], &blk) ⇒ HashMapper
constructor
A new instance of HashMapper.
- #run(object = {}, state = {}) ⇒ Object (also: #call)
Constructor Details
#initialize(opts = [], &blk) ⇒ HashMapper
Returns a new instance of HashMapper.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/hash-mapper.rb', line 10 def initialize(opts = [], &blk) @opts = case opts when Array { keep: opts } when Hash opts end @mapper = Dsl.new @mapper.evaluate(&blk) unless blk.nil? end |
Instance Method Details
#run(object = {}, state = {}) ⇒ Object Also known as: call
21 22 23 24 25 26 |
# File 'lib/hash-mapper.rb', line 21 def run(object = {}, state = {}) object = object state = state.dup state = process_initializer(object, state) _run(object, state) end |