class MaponClient::Resources

Public Class Methods

descendants() click to toggle source
# File lib/mapon_client/resources.rb, line 22
def self.descendants
  @descendants ||= begin
    classes = constants.map { |const_name| const_get(const_name) }
    classes.select { |klass| klass.name.end_with?('Resource') }
  end
end
generate_action(name:, method: 'get') click to toggle source
# File lib/mapon_client/resources.rb, line 29
def self.generate_action(name:, method: 'get')
  class_eval %{
    def #{name}(params = {})
      raw_response = @client['#{resource_name}/#{name}'].#{method}(
        params: with_key(params)
      ).body

      parse_repsonse(raw_response)
    end
  }
end
new(client) click to toggle source
# File lib/mapon_client/resources.rb, line 41
def initialize(client)
  @client = client
end

Public Instance Methods

parse_repsonse(response) click to toggle source
# File lib/mapon_client/resources.rb, line 49
def parse_repsonse(response)
  @client.parser_class.new(response).parse
end
with_key(params) click to toggle source
# File lib/mapon_client/resources.rb, line 45
def with_key(params)
  @client.with_key(params)
end