class Koine::Attributes::Adapter::HashOf
Public Class Methods
new(key_adapter, value_adapter)
click to toggle source
# File lib/koine/attributes/adapter/hash_of.rb, line 7 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
Public Instance Methods
for_keys()
click to toggle source
# File lib/koine/attributes/adapter/hash_of.rb, line 13 def for_keys @key_adapter end
for_values()
click to toggle source
# File lib/koine/attributes/adapter/hash_of.rb, line 17 def for_values @value_adapter end
with_attribute_name(name)
click to toggle source
Calls superclass method
Koine::Attributes::Adapter::Base#with_attribute_name
# File lib/koine/attributes/adapter/hash_of.rb, line 21 def with_attribute_name(name) @key_adapter.with_attribute_name(name) @value_adapter.with_attribute_name(name) super(name) end
Private Instance Methods
coerce_not_nil(hash)
click to toggle source
# File lib/koine/attributes/adapter/hash_of.rb, line 29 def coerce_not_nil(hash) secure do {}.tap do |new_hash| hash.each do |key, value| key = @key_adapter.coerce(key) value = @value_adapter.coerce(value) new_hash[key] = value end end end end