Class: BananaPeels::API

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

Defined Under Namespace

Classes: Proxy

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ API

Returns a new instance of API.



86
87
88
# File 'lib/banana_peels/api.rb', line 86

def initialize(api_key)
  @api_key = api_key
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



90
91
92
# File 'lib/banana_peels/api.rb', line 90

def method_missing(method, *args)
  Proxy.new(@api_key, method)
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



58
59
60
# File 'lib/banana_peels/api.rb', line 58

def api_key
  @api_key
end

Class Method Details

.cache?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/banana_peels/api.rb', line 72

def cache?
  ['true', 't', 'yes', 'y', 'on'].include?(ENV['BANANA_PEELS_CACHE'].to_s.downcase)
end

.cache_get(key) ⇒ Object



63
64
65
# File 'lib/banana_peels/api.rb', line 63

def cache_get(key)
  cache[key]
end

.cache_set(key, value) ⇒ Object



67
68
69
70
# File 'lib/banana_peels/api.rb', line 67

def cache_set(key, value)
  cache[key] = value if cache?
  value
end