Sha256: 3e191fc09f02d39c682fd4881b2c0d0a339eb5abd0abef339f5d41618b71aa62

Contents?: true

Size: 854 Bytes

Versions: 1

Compression:

Stored size: 854 Bytes

Contents

module OptimizePlayer
  module Proxies
    class BaseProxy
      attr_reader :client

      def initialize(client)
        @client = client
      end

      def inspect()
        "#<#{self.class}:0x#{self.object_id.to_s(16)}"
      end

      def all(attrs={})
        response = client.send_request(entity_name, :get, attrs)
        Converter.convert_to_object(self, response)
      end

      def find(id)
        response = client.send_request("#{entity_name}/#{id}", :get)
        Converter.convert_to_object(self, response)
      end

      def create(attrs)
        response = client.send_request(entity_name, :post, attrs)
        Converter.convert_to_object(self, response)
      end

      protected

        def entity_name
          raise NotImplementedError.new('You should implement actions on its subclasses')
        end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
optimizeplayer-0.0.1 lib/optimize_player/proxies/base_proxy.rb