Class: MailRU::API::DSL
- Inherits:
-
Object
- Object
- MailRU::API::DSL
- Defined in:
- lib/mailru-api/dsl.rb
Instance Method Summary collapse
- #api(name, method = :get, secure = Request::Secure::Any) ⇒ Object
-
#initialize(api, group, &block) ⇒ DSL
constructor
A new instance of DSL.
Constructor Details
#initialize(api, group, &block) ⇒ DSL
Returns a new instance of DSL.
6 7 8 9 10 |
# File 'lib/mailru-api/dsl.rb', line 6 def initialize api, group, &block @api = api @group = group instance_eval(&block) if block_given? end |
Instance Method Details
#api(name, method = :get, secure = Request::Secure::Any) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/mailru-api/dsl.rb', line 12 def api name, method = :get, secure = Request::Secure::Any raise Error.create(0, 'HTTP method must be GET or POST!') unless [:get, :post].include?(method) method(SEND).call(:define_singleton_method, underscore(name)) do |params = {}| return @api.get("#{@group}.#{name}", params, secure) if method == :get return @api.post("#{@group}.#{name}", params, secure) if method == :post end end |