Class: Polar::Base

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

Direct Known Subclasses

Response, User

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Base

Returns a new instance of Base.



4
5
6
# File 'lib/polar/base.rb', line 4

def initialize(data)
  @data = data
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *attrs) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/polar/base.rb', line 8

def method_missing(method_name, *attrs)
  if @data.has_key?(method_name.to_s)
    return @data[method_name.to_s] 
  else
    raise("No data for: #{method_name}")
  end 
end

Instance Method Details

#to_hObject



16
17
18
# File 'lib/polar/base.rb', line 16

def to_h
  @data
end