Sha256: 40aceee688e7dec95bfdb0bfbf042e75fa2f815245703566a240764c99c946b0

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

module Givepulse
    class Resource
        attr_reader :client

        attr_accessor :path

        def initialize(client, path, supported_methods)
            @client ||= client
            @path ||= path
            @supported_methods ||= supported_methods.clone
        end

        def get(options = nil)
            raise Givepulse::UnsupportedMethod, self.class unless @supported_methods.include?(__method__)
            @client.connection.get(@path, options)
        end

        def create(data)
            raise Givepulse::UnsupportedMethod, self.class unless @supported_methods.include?(__method__)
            @client.connection.post(@path, data)
        end

        def update(id, data)
            raise Givepulse::UnsupportedMethod, self.class unless @supported_methods.include?(__method__)
            @client.connection.put("#{@path}/#{id}", data)
        end

        def delete(id)
            raise Givepulse::UnsupportedMethod, self.class unless @supported_methods.include?(__method__)
            @client.connection.delete("#{@path}/#{id}")
        end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
givepulse-0.1.1 lib/givepulse/resource.rb
givepulse-0.1.0 lib/givepulse/resource.rb