Class: HashMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/hash-mapper.rb,
lib/hash-mapper/dsl.rb

Defined Under Namespace

Classes: Context, Dsl, Input

Constant Summary collapse

VERSION =
"0.0.1"

Instance Method Summary collapse

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