Class: Depth::ComplexHash

Inherits:
Object
  • Object
show all
Includes:
Actions, Enumeration::Enumerable
Defined in:
lib/depth/complex_hash.rb

Constant Summary collapse

DEFAULT_KEY_TRANSFORMER =
proc { |obj, key| key }
DEFAULT_NEXT_PROC =
proc { |obj, key| obj[key] }
DEFAULT_CREATION_PROC =
proc { |obj, key, val| obj[key] = val }

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Enumeration::Enumerable

#each, #each_with_object, #map, #map!, #map_keys, #map_keys!, #map_values, #map_values!, #reduce, #reject, #select

Methods included from Actions

#alter, #delete, #find, #set

Constructor Details

#initialize(base = {}, key_transformer: DEFAULT_KEY_TRANSFORMER, next_proc: DEFAULT_NEXT_PROC, creation_proc: DEFAULT_CREATION_PROC) ⇒ ComplexHash

Returns a new instance of ComplexHash.



10
11
12
13
14
15
16
17
18
# File 'lib/depth/complex_hash.rb', line 10

def initialize(base = {},
               key_transformer: DEFAULT_KEY_TRANSFORMER,
               next_proc: DEFAULT_NEXT_PROC,
               creation_proc: DEFAULT_CREATION_PROC)
  @base = base
  @next_proc = next_proc
  @creation_proc = creation_proc
  @key_transformer = key_transformer
end

Instance Attribute Details

#baseObject (readonly) Also known as: to_h

Returns the value of attribute base.



8
9
10
# File 'lib/depth/complex_hash.rb', line 8

def base
  @base
end

#creation_procObject (readonly)

Returns the value of attribute creation_proc.



8
9
10
# File 'lib/depth/complex_hash.rb', line 8

def creation_proc
  @creation_proc
end

#key_transformerObject (readonly)

Returns the value of attribute key_transformer.



8
9
10
# File 'lib/depth/complex_hash.rb', line 8

def key_transformer
  @key_transformer
end

#next_procObject (readonly)

Returns the value of attribute next_proc.



8
9
10
# File 'lib/depth/complex_hash.rb', line 8

def next_proc
  @next_proc
end