Class: PearsonKitchenManager
- Inherits:
-
Object
- Object
- PearsonKitchenManager
- Includes:
- HTTParty
- Defined in:
- lib/pearson_kitchen_manager.rb,
lib/pearson_kitchen_manager/version.rb
Constant Summary collapse
- VERSION =
"0.0.5"
Class Attribute Summary collapse
-
.api_key ⇒ Object
Returns the value of attribute api_key.
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Class Method Summary collapse
Instance Method Summary collapse
- #base_api_url ⇒ Object
- #get_exporter ⇒ Object
-
#initialize(api_key = nil, extra_params = {}) ⇒ PearsonKitchenManager
constructor
A new instance of PearsonKitchenManager.
Constructor Details
#initialize(api_key = nil, extra_params = {}) ⇒ PearsonKitchenManager
Returns a new instance of PearsonKitchenManager.
17 18 19 20 |
# File 'lib/pearson_kitchen_manager.rb', line 17 def initialize(api_key = nil, extra_params = {}) @api_key = api_key || ENV['PEARSON_API_KEY'] || self.class.api_key @default_params = {:apikey => @api_key}.merge(extra_params) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object (protected)
83 84 85 86 87 |
# File 'lib/pearson_kitchen_manager.rb', line 83 def method_missing(method, *args) method = method.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } #Thanks for the gsub, Rails method = method[0].chr.downcase + method[1..-1].gsub(/aim$/i, 'AIM') call(method, *args) end |
Class Attribute Details
.api_key ⇒ Object
Returns the value of attribute api_key.
90 91 92 |
# File 'lib/pearson_kitchen_manager.rb', line 90 def api_key @api_key end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
15 16 17 |
# File 'lib/pearson_kitchen_manager.rb', line 15 def api_key @api_key end |
#timeout ⇒ Object
Returns the value of attribute timeout.
15 16 17 |
# File 'lib/pearson_kitchen_manager.rb', line 15 def timeout @timeout end |
Class Method Details
.method_missing(sym, *args, &block) ⇒ Object
92 93 94 |
# File 'lib/pearson_kitchen_manager.rb', line 92 def method_missing(sym, *args, &block) new(self.api_key).send(sym, *args, &block) end |
Instance Method Details
#base_api_url ⇒ Object
31 32 33 |
# File 'lib/pearson_kitchen_manager.rb', line 31 def base_api_url "http://api.pearson.com/kitchen-manager/v1/" end |
#get_exporter ⇒ Object
27 28 29 |
# File 'lib/pearson_kitchen_manager.rb', line 27 def get_exporter GibbonExport.new(@api_key, @default_params) end |