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.
4 5 6 7 8 |
# File 'lib/mailru/api/dsl.rb', line 4 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
10 11 12 13 14 15 16 17 |
# File 'lib/mailru/api/dsl.rb', line 10 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) __send__(: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 |