Class: RMeetup::Destroyer::Base
- Inherits:
-
Object
- Object
- RMeetup::Destroyer::Base
- Defined in:
- lib/rmeetup/destroyer/base.rb
Overview
RMeetup::Destroyer::Base
Base destroyer class that other destroyers will inherit from.
Direct Known Subclasses
Instance Method Summary collapse
- #build_path(options) ⇒ Object
-
#delete(options = {}) ⇒ Object
Delete and return a response based on a set of options.
-
#initialize ⇒ Base
constructor
A new instance of Base.
-
#query(options) ⇒ Object
Create a query string from an options hash.
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
21 22 23 24 |
# File 'lib/rmeetup/destroyer/base.rb', line 21 def initialize @type = nil @id = nil end |
Instance Method Details
#build_path(options) ⇒ Object
50 51 52 |
# File 'lib/rmeetup/destroyer/base.rb', line 50 def build_path() base_url + query() end |
#delete(options = {}) ⇒ Object
Delete and return a response based on a set of options. Override this method to ensure necessary options are passed for the request.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rmeetup/destroyer/base.rb', line 31 def delete( = {}) raise NotConfiguredError, /deletes only possible with a concrete destroyer/ if @type.nil? res = delete_response(base_url, ) data = JSON.parse(res.body) unless res.is_a?(Net::HTTPSuccess) # Check to see if the api returned an error if data.has_key?('problem') raise ApiError.new(data['details'], build_path()) else raise NoResponseError.new end end true end |
#query(options) ⇒ Object
Create a query string from an options hash
55 56 57 |
# File 'lib/rmeetup/destroyer/base.rb', line 55 def query() '?' + URI.encode_www_form() end |