class AWS::Core::Data


data.people.map(&:name) #=> [‘john’,‘jane’]<br><br>data.people.name #=> ‘jane’<br>data.people.name #=> ‘john’
]})
{:name => ‘jane’},
{:name => ‘john’},
:people => [
data = AWS::Core::Data.new(
method-missing access.
data returned is correctly wrapped so you can continue using
Arrays are wrapped in {Data::List} objects. They ensure any
== Nested Arrays
data.a.b.c #=> ‘abc’
data = AWS::Core::Data.new(:a => { :b => { :c => ‘abc’ }})
the structure.
If the data contains nested hashes you can chain methods into
== Nested Hashes
data.d? #=> raises NoMethodError
data.c? #=> true
Given the structure above you can also use question-mark methods.
== Boolean Methods
data.d #=> raises NoMethodError
data.c #=> true
data.b #=> 2
data.a #=> 1
data = AWS::Core::Data.new({ :a => 1, :b => 2, :c => true })
are symbols.
You can access hash content with methods if their keys
== Method Missing Access
method missing access to the hash contents.
Data is a light wrapper around a Ruby hash that provides

def _remove_question_mark method_name

def _remove_question_mark method_name
  case method_name
  when Symbol then method_name.to_s.sub(/\?$/, '').to_sym
  when String then method_name.sub(/\?$/, '')
  else method_name
  end
end

def cast value

Returns:
  • (Data, Data::List, Object) - Wraps hashes and lists with

Parameters:
  • value (Object) -- The value to conditionally wrap.
def cast value
  case value
  when Hash then Data.new(value)
  when Array then Data::List.new(value)
  else value
  end
end

def initialize data

Parameters:
  • data (Hash) -- The ruby hash of data you need wrapped.
def initialize data
  @data = data
end

def inspect

Returns:
  • (String) -
def inspect
  @data.inspect
end

def kind_of? klass

Other tags:
    Private: -
def kind_of? klass
  if klass == Hash
    true
  else
    super
  end
end

def method_missing method_name, *args, &block

def method_missing method_name, *args, &block
  if 
    args.empty? and !block_given? and
    key = _remove_question_mark(method_name) and
    @data.has_key?(key)
  then
    Data.cast(@data[key])
  else
    super
  end
end

def respond_to? method_name

Returns:
  • (Boolean) - Returns true if this data object will

Parameters:
  • method_name (String, Symbol) --
def respond_to? method_name
  @data.key?(_remove_question_mark(method_name)) or
    @data.respond_to?(method_name)
end

def to_a

Returns:
  • (Array) -
def to_a
  @data.to_a
end

def to_hash

Returns:
  • (Hash) - Returns contents of this Data object as a raw hash.
def to_hash
  @data
end