Class: Koine::Attributes::Adapter::HashOf

Inherits:
Base
  • Object
show all
Defined in:
lib/koine/attributes/adapter/hash_of.rb

Instance Attribute Summary

Attributes inherited from Base

#attribute_name

Instance Method Summary collapse

Methods inherited from Base

#coerce, #default_value, #with_default_value, #with_nil_value

Constructor Details

#initialize(key_adapter, value_adapter) ⇒ HashOf

Returns a new instance of HashOf.



5
6
7
8
9
# File 'lib/koine/attributes/adapter/hash_of.rb', line 5

def initialize(key_adapter, value_adapter)
  @key_adapter = key_adapter || raise(ArgumentError, 'Invalid key adapter')
  @value_adapter = value_adapter || raise(ArgumentError, 'Invalid value adapter')
  with_default_value({})
end

Instance Method Details

#for_keysObject



11
12
13
# File 'lib/koine/attributes/adapter/hash_of.rb', line 11

def for_keys
  @key_adapter
end

#for_valuesObject



15
16
17
# File 'lib/koine/attributes/adapter/hash_of.rb', line 15

def for_values
  @value_adapter
end