Class: TweetStream::Hash

Inherits:
Hash
  • Object
show all
Defined in:
lib/tweetstream/hash.rb

Overview

:nodoc: all

Direct Known Subclasses

Status, User

Instance Method Summary collapse

Constructor Details

#initialize(other_hash = {}) ⇒ Hash

Returns a new instance of Hash.



2
3
4
5
6
7
8
# File 'lib/tweetstream/hash.rb', line 2

def initialize(other_hash = {})
  other_hash.keys.each do |key|
    value = other_hash[key]
    value = TweetStream::Hash.new(value) if value.is_a?(::Hash)
    self[key.to_sym] = value
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/tweetstream/hash.rb', line 10

def method_missing(method_name, *args)
  if key?(method_name.to_sym)
    self[method_name.to_sym]
  else
    super
  end
end