Module: Mitake::API::ClassMethods Private
- Defined in:
- lib/mitake/api.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#execute(params = {}, &_block) {|items| ... } ⇒ Mitake::API
private
Execute API.
-
#map(from, to) ⇒ Object
private
Set response field mapping.
-
#method(method = nil) ⇒ String
private
Set/Get the api method.
-
#path(path = nil) ⇒ String
private
Set/Get the api path.
Instance Method Details
#execute(params = {}, &_block) {|items| ... } ⇒ Mitake::API
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Execute API
74 75 76 77 78 79 80 81 82 |
# File 'lib/mitake/api.rb', line 74 def execute(params = {}, &_block) res = request(params) raise Mitake::API::Error, res.code unless res.is_a?(Net::HTTPOK) items = Parser.new(res).parse.map { |item| rename_attribute(item) } return items.map { |item| new(item) } unless block_given? yield items end |
#map(from, to) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set response field mapping
61 62 63 64 |
# File 'lib/mitake/api.rb', line 61 def map(from, to) @mapping ||= {} @mapping[from.to_s] = to.to_s end |
#method(method = nil) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set/Get the api method
48 49 50 51 52 |
# File 'lib/mitake/api.rb', line 48 def method(method = nil) return @method if method.nil? @method = method.to_s.capitalize end |
#path(path = nil) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set/Get the api path
35 36 37 38 39 |
# File 'lib/mitake/api.rb', line 35 def path(path = nil) return @path if path.nil? @path = path end |