Class: DianPing
- Inherits:
-
Object
- Object
- DianPing
- Includes:
- HTTParty
- Defined in:
- lib/dian_ping.rb,
lib/dianping/common.rb,
lib/dianping/railtie.rb,
lib/dianping/business.rb,
lib/dianping/parameter.rb,
lib/generators/dianping/install_generator.rb
Defined Under Namespace
Modules: Business, Common, Generators Classes: Parameter, Railtie
Constant Summary collapse
- VERSION =
'0.1.0'
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#secret ⇒ Object
Returns the value of attribute secret.
Instance Method Summary collapse
- #get(route, param = {}) ⇒ Hash
-
#initialize(opts = {}) ⇒ DianPing
constructor
A new instance of DianPing.
Constructor Details
#initialize(opts = {}) ⇒ DianPing
Returns a new instance of DianPing.
15 16 17 |
# File 'lib/dian_ping.rb', line 15 def initialize(opts = {}) @key, @secret = opts.values_at(:key, :secret) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object (private)
45 46 47 48 49 50 51 52 |
# File 'lib/dian_ping.rb', line 45 def method_missing(method_name, *args, &block) super unless parameter.respond_to?(method_name) if args.empty? parameter.send(method_name) else parameter.send(method_name, args.first) end end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
11 12 13 |
# File 'lib/dian_ping.rb', line 11 def key @key end |
#secret ⇒ Object
Returns the value of attribute secret.
11 12 13 |
# File 'lib/dian_ping.rb', line 11 def secret @secret end |
Instance Method Details
#get(route, param = {}) ⇒ Hash
27 28 29 30 31 |
# File 'lib/dian_ping.rb', line 27 def get(route, param = {}) param[:sign] = signature(param) param[:appkey] = @key self.class.get route, query: param end |