Sha256: 653016bd59f7e4372a0ca35cb1123d2b31fa2bc1e67661fb6590449885873c24
Contents?: true
Size: 973 Bytes
Versions: 13
Compression:
Stored size: 973 Bytes
Contents
module Myfinance module Resources class Base attr_accessor :http def initialize(http) @http = http end private def build_search_endpoint(params) query_string = query(params).join("&") URI.encode("#{endpoint}?#{query_string}") end def query(params) page = params.delete(:page) query = params.map { |key, value| "search[#{key}]=#{value}" } query << "page=#{page}" if page query end def respond_with_collection(response) collection_klass = Myfinance::Entities.const_get("#{entity_klass_name}Collection") collection_klass.build(response) end def respond_with_object(response, key) entity_klass = Myfinance::Entities.const_get(entity_klass_name) entity_klass.new(response.parsed_body(key)) end def entity_klass_name self.class.to_s.gsub("Resources", "Entities") end end end end
Version data entries
13 entries across 13 versions & 1 rubygems