Class: BabyTooth::Client

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token, path) ⇒ Client

Returns a new instance of Client.



13
14
15
16
# File 'lib/baby_tooth/client.rb', line 13

def initialize(access_token, path)
  self.access_token = access_token
  self.path = path
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



3
4
5
# File 'lib/baby_tooth/client.rb', line 3

def access_token
  @access_token
end

#pathObject

Returns the value of attribute path.



3
4
5
# File 'lib/baby_tooth/client.rb', line 3

def path
  @path
end

Class Method Details

.exposes_keys(*keys) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/baby_tooth/client.rb', line 22

def self.exposes_keys(*keys)
  keys.each do |key|
    define_method key do
      body[key.to_s]
    end
  end
end

Instance Method Details

#[](key) ⇒ Object



5
6
7
# File 'lib/baby_tooth/client.rb', line 5

def [](key)
  body[key]
end

#bodyObject



9
10
11
# File 'lib/baby_tooth/client.rb', line 9

def body
  @body ||= retrieve_body
end

#resource_class_nameObject



18
19
20
# File 'lib/baby_tooth/client.rb', line 18

def resource_class_name
  self.class.name.split('::').last
end