Sha256: 6b64d5711828a1309f54bbb5f927816c7a361e366862a026c6b59a96e35f0271

Contents?: true

Size: 630 Bytes

Versions: 12

Compression:

Stored size: 630 Bytes

Contents

module Myfinance
  module Resources
    class Base

      attr_accessor :http

      def initialize(http)
        @http = http
      end

      private

      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

12 entries across 12 versions & 1 rubygems

Version Path
myfinance-1.1.0 lib/myfinance/resources/base.rb
myfinance-1.0.0 lib/myfinance/resources/base.rb
myfinance-0.7.0 lib/myfinance/resources/base.rb
myfinance-0.6.0 lib/myfinance/resources/base.rb
myfinance-0.5.0 lib/myfinance/resources/base.rb
myfinance-0.4.0 lib/myfinance/resources/base.rb
myfinance-0.3.3 lib/myfinance/resources/base.rb
myfinance-0.3.2 lib/myfinance/resources/base.rb
myfinance-0.3.1 lib/myfinance/resources/base.rb
myfinance-0.3.0 lib/myfinance/resources/base.rb
myfinance-0.2.0 lib/myfinance/resources/base.rb
myfinance-0.1.0 lib/myfinance/resources/base.rb