Class: RSchema::Coercers::FixedHash::SymbolizeKeys
- Inherits:
-
Object
- Object
- RSchema::Coercers::FixedHash::SymbolizeKeys
- Defined in:
- lib/rschema/coercers/fixed_hash/symbolize_keys.rb
Instance Attribute Summary collapse
-
#hash_attributes ⇒ Object
readonly
Returns the value of attribute hash_attributes.
Class Method Summary collapse
Instance Method Summary collapse
- #call(value) ⇒ Object
-
#initialize(fixed_hash_schema) ⇒ SymbolizeKeys
constructor
A new instance of SymbolizeKeys.
- #will_affect?(value) ⇒ Boolean
Constructor Details
#initialize(fixed_hash_schema) ⇒ SymbolizeKeys
Returns a new instance of SymbolizeKeys.
14 15 16 17 |
# File 'lib/rschema/coercers/fixed_hash/symbolize_keys.rb', line 14 def initialize(fixed_hash_schema) #TODO: make fixed hash attributes frozen, and eliminate dup @hash_attributes = fixed_hash_schema.attributes.map(&:dup) end |
Instance Attribute Details
#hash_attributes ⇒ Object (readonly)
Returns the value of attribute hash_attributes.
8 9 10 |
# File 'lib/rschema/coercers/fixed_hash/symbolize_keys.rb', line 8 def hash_attributes @hash_attributes end |
Class Method Details
.build(schema) ⇒ Object
10 11 12 |
# File 'lib/rschema/coercers/fixed_hash/symbolize_keys.rb', line 10 def self.build(schema) new(schema) end |
Instance Method Details
#call(value) ⇒ Object
19 20 21 |
# File 'lib/rschema/coercers/fixed_hash/symbolize_keys.rb', line 19 def call(value) Result.success(symbolize_keys(value)) end |
#will_affect?(value) ⇒ Boolean
23 24 25 |
# File 'lib/rschema/coercers/fixed_hash/symbolize_keys.rb', line 23 def will_affect?(value) keys_to_symbolize(hash).any? end |