Class: Mashery::ApiObjectBase
- Inherits:
-
Object
- Object
- Mashery::ApiObjectBase
- Defined in:
- lib/mashery/api_object_base.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data) ⇒ ApiObjectBase
constructor
A new instance of ApiObjectBase.
Constructor Details
#initialize(data) ⇒ ApiObjectBase
Returns a new instance of ApiObjectBase.
21 22 23 24 |
# File 'lib/mashery/api_object_base.rb', line 21 def initialize(data) # XXX: use setter methods data.each_pair {|k, v| instance_variable_set("@#{k}".to_sym, v)} end |
Class Method Details
.create(fields = {}) ⇒ Object
3 4 5 6 |
# File 'lib/mashery/api_object_base.rb', line 3 def self.create(fields = {}) # XXX: only send fields that aren't read-only new(Mashery.client.call_remote(method('create'), fields)) end |
.delete(id) ⇒ Object
13 14 15 |
# File 'lib/mashery/api_object_base.rb', line 13 def self.delete(id) Mashery.client.call_remote(method('delete'), id) end |
.fetch(id) ⇒ Object
8 9 10 11 |
# File 'lib/mashery/api_object_base.rb', line 8 def self.fetch(id) data = Mashery.client.call_remote(method('fetch'), id) data.nil?? nil : new(data) end |
.method(basename) ⇒ Object
17 18 19 |
# File 'lib/mashery/api_object_base.rb', line 17 def self.method(basename) "#{name.split(/\:\:/).last.downcase}.#{basename}" end |