Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/AWS.rb

Overview

A custom implementation of Hash that allows us to access hash values using dot notation

Examples:

Access the hash keys in the standard way or using dot notation

foo[:bar] => "baz"
foo.bar => "baz"

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



26
27
28
29
30
# File 'lib/AWS.rb', line 26

def method_missing(meth, *args, &block)
  if args.size == 0
    self[meth.to_s] || self[meth.to_sym]
  end
end

Instance Method Details

#does_not_have?(key) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/AWS.rb', line 40

def does_not_have?(key)
  self[key].nil? || self[key].to_s.empty?
end

#has?(key) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/AWS.rb', line 36

def has?(key)
  self[key] && !self[key].to_s.empty?
end

#typeObject



32
33
34
# File 'lib/AWS.rb', line 32

def type
  self['type']
end