Class: Jsapi::Controller::Response::HashReader

Inherits:
Object
  • Object
show all
Defined in:
lib/jsapi/controller/response.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ HashReader

Returns a new instance of HashReader.



21
22
23
# File 'lib/jsapi/controller/response.rb', line 21

def initialize(hash)
  @hash = hash
end

Instance Method Details

#[](key) ⇒ Object



25
26
27
28
29
30
# File 'lib/jsapi/controller/response.rb', line 25

def [](key)
  return unless @hash.key?(key)

  (@read_keys ||= []) << key
  @hash[key]
end

#additional_propertiesObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/jsapi/controller/response.rb', line 32

def additional_properties
  if @hash.key?('additional_properties')
    @hash['additional_properties']
  elsif @hash.key?(:additional_properties)
    @hash[:additional_properties]
  elsif @read_keys
    @hash.except(*@read_keys)
  else
    @hash
  end
end