Class: Givepulse::Resource
- Inherits:
-
Object
- Object
- Givepulse::Resource
- Defined in:
- lib/givepulse/resource.rb
Direct Known Subclasses
Givepulse::Resources::Affiliations, Givepulse::Resources::Education, Givepulse::Resources::Events, Givepulse::Resources::Groups, Givepulse::Resources::Impacts, Givepulse::Resources::Memberships, Givepulse::Resources::Registrations, Givepulse::Resources::Users
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #create(data) ⇒ Object
- #delete(id) ⇒ Object
- #get(options = nil) ⇒ Object
-
#initialize(client, path, supported_methods) ⇒ Resource
constructor
A new instance of Resource.
- #update(id, data) ⇒ Object
Constructor Details
#initialize(client, path, supported_methods) ⇒ Resource
Returns a new instance of Resource.
7 8 9 10 11 |
# File 'lib/givepulse/resource.rb', line 7 def initialize(client, path, supported_methods) @client ||= client @path ||= path @supported_methods ||= supported_methods.clone end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/givepulse/resource.rb', line 3 def client @client end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/givepulse/resource.rb', line 5 def path @path end |
Instance Method Details
#create(data) ⇒ Object
18 19 20 21 |
# File 'lib/givepulse/resource.rb', line 18 def create(data) raise Givepulse::UnsupportedMethod, self.class unless @supported_methods.include?(__method__) @client.connection.post(@path, data) end |
#delete(id) ⇒ Object
28 29 30 31 |
# File 'lib/givepulse/resource.rb', line 28 def delete(id) raise Givepulse::UnsupportedMethod, self.class unless @supported_methods.include?(__method__) @client.connection.delete("#{@path}/#{id}") end |
#get(options = nil) ⇒ Object
13 14 15 16 |
# File 'lib/givepulse/resource.rb', line 13 def get( = nil) raise Givepulse::UnsupportedMethod, self.class unless @supported_methods.include?(__method__) @client.connection.get(@path, ) end |
#update(id, data) ⇒ Object
23 24 25 26 |
# File 'lib/givepulse/resource.rb', line 23 def update(id, data) raise Givepulse::UnsupportedMethod, self.class unless @supported_methods.include?(__method__) @client.connection.put("#{@path}/#{id}", data) end |