class GmHashWrapper::HashWrapper
Attributes
body[R]
Public Class Methods
new(body)
click to toggle source
# File lib/gm_hash_wrapper/hash_wrapper.rb, line 6 def initialize(body) @body = ActiveSupport::HashWithIndifferentAccess.new(body) end
Public Instance Methods
as_json(options = {})
click to toggle source
# File lib/gm_hash_wrapper/hash_wrapper.rb, line 17 def as_json(options = {}) @body end
each(&block)
click to toggle source
# File lib/gm_hash_wrapper/hash_wrapper.rb, line 29 def each(&block) body.each &block end
method_missing(meth, *args, &block)
click to toggle source
# File lib/gm_hash_wrapper/hash_wrapper.rb, line 33 def method_missing meth, *args, &block if @body.has_key?(meth) if @body[meth].kind_of?(Hash) return HashWrapper.new(@body[meth]) elsif @body[meth].kind_of?(Array) return @body[meth].map do |x| if x.kind_of?(Hash) HashWrapper.new(x) else x end end else return @body[meth] end end nil end
nil?()
click to toggle source
# File lib/gm_hash_wrapper/hash_wrapper.rb, line 21 def nil? @body.keys.empty? end
present?()
click to toggle source
# File lib/gm_hash_wrapper/hash_wrapper.rb, line 25 def present? @body.keys.any? end
respond_to_missing?(meth, include_private = false)
click to toggle source
Calls superclass method
# File lib/gm_hash_wrapper/hash_wrapper.rb, line 52 def respond_to_missing?(meth, include_private = false) @body.has_key?(meth) || super end
set_data(key, value)
click to toggle source
# File lib/gm_hash_wrapper/hash_wrapper.rb, line 10 def set_data(key, value) @body[key.to_s] = value end
to_h()
click to toggle source
# File lib/gm_hash_wrapper/hash_wrapper.rb, line 13 def to_h @body end