Class: DBC::DbcObject
- Inherits:
-
Object
- Object
- DBC::DbcObject
- Defined in:
- lib/dbc/dbc_object.rb
Direct Known Subclasses
ApiKey, Challenge, ChallengeAttempt, Cohort, Exercise, ExerciseAttempt, User
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ DbcObject
constructor
A new instance of DbcObject.
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( = {}) api_response = DBC.request(self.endpoint, ) 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 |