Class: DBC::DbcObject
- Inherits:
-
Object
show all
- Defined in:
- lib/dbc/dbc_object.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(attributes) ⇒ DbcObject
Returns a new instance of DbcObject.
3
4
5
6
7
8
|
# File 'lib/dbc/dbc_object.rb', line 3
def initialize(attributes)
attributes.each do |key, value|
instance_variable_set("@#{key}", value)
self.class.send(:define_method, key){ value }
end
end
|
Class Method Details
.all(options = {}) ⇒ Object
14
15
16
17
|
# File 'lib/dbc/dbc_object.rb', line 14
def self.all(options = {})
api_response = DBC.request(self.endpoint, options)
self.create_dbc_objects(api_response)
end
|
.endpoint(id = '') ⇒ Object
10
11
12
|
# File 'lib/dbc/dbc_object.rb', line 10
def self.endpoint(id = '')
'/' + id.to_s
end
|
.find(id) ⇒ Object
19
20
21
22
|
# File 'lib/dbc/dbc_object.rb', line 19
def self.find(id)
api_response = DBC.request(self.endpoint(id))
self.create_dbc_object(api_response)
end
|