Class: NfseSjc::ResponseHash
- Inherits:
-
Object
- Object
- NfseSjc::ResponseHash
- Defined in:
- lib/nfse_sjc/response_hash.rb
Instance Method Summary collapse
-
#initialize(hash) ⇒ ResponseHash
constructor
A new instance of ResponseHash.
- #to_deep_symbolized_h ⇒ Object
Constructor Details
#initialize(hash) ⇒ ResponseHash
Returns a new instance of ResponseHash.
3 4 5 |
# File 'lib/nfse_sjc/response_hash.rb', line 3 def initialize(hash) @hash = hash end |
Instance Method Details
#to_deep_symbolized_h ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/nfse_sjc/response_hash.rb', line 7 def to_deep_symbolized_h @hash.inject(Hash.new) do |h, (k, v)| h.merge!({ k.snakecase.to_sym => ( case v when Hash ResponseHash.new(v).to_deep_symbolized_h when Array v.map{|item| ResponseHash.new(item).to_deep_symbolized_h} else v end ) }) end end |