Class: Darthjee::CoreExt::Hash::ValueChanger

Inherits:
Object
  • Object
show all
Defined in:
lib/darthjee/core_ext/hash/value_changer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, &block) ⇒ ValueChanger

Returns a new instance of ValueChanger.



9
10
11
12
13
14
15
16
# File 'lib/darthjee/core_ext/hash/value_changer.rb', line 9

def initialize(options, &block)
  @options = {
    recursive: true,
    skip_inner: true
  }.merge(options)

  @block = block
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



7
8
9
# File 'lib/darthjee/core_ext/hash/value_changer.rb', line 7

def block
  @block
end

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/darthjee/core_ext/hash/value_changer.rb', line 7

def options
  @options
end

Instance Method Details

#change(object) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/darthjee/core_ext/hash/value_changer.rb', line 18

def change(object)
  if object.respond_to?(:change_values)
    change_hash(object)
  elsif iterable?(object)
    change_array(object)
  end
end