Sha256: 9b11ac4b5e2a21f740e484fc720faeccc0161f7ec2ece25c5ce67fbf99bf77e5
Contents?: true
Size: 977 Bytes
Versions: 2
Compression:
Stored size: 977 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("&") "#{endpoint}?#{query_string}" end def query(params) page = params.delete(:page) query = params.map { |key, value| "search[#{key}]=#{CGI.escape(value.to_s)}" } 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
myfinance-1.8.2 | lib/myfinance/resources/base.rb |
myfinance-1.8.1 | lib/myfinance/resources/base.rb |