Class: TimeCamp::Resource
- Inherits:
-
Object
- Object
- TimeCamp::Resource
- Defined in:
- lib/ruby-timecamp/resource.rb
Class Method Summary collapse
-
.resource_name ⇒ Object
CLASS METHODS #.
Instance Method Summary collapse
-
#attributes ⇒ Object
INSTANCE METHODS #.
-
#initialize(response) ⇒ Resource
constructor
A new instance of Resource.
Constructor Details
#initialize(response) ⇒ Resource
Returns a new instance of Resource.
4 5 6 |
# File 'lib/ruby-timecamp/resource.rb', line 4 def initialize(response) load_attributes(response.with_indifferent_access) end |
Class Method Details
.resource_name ⇒ Object
CLASS METHODS #
12 13 14 |
# File 'lib/ruby-timecamp/resource.rb', line 12 def self.resource_name return self.to_s.demodulize.pluralize.downcase end |
Instance Method Details
#attributes ⇒ Object
INSTANCE METHODS #
20 21 22 |
# File 'lib/ruby-timecamp/resource.rb', line 20 def attributes return Hash[instance_variables.map { |name| [name, instance_variable_get(name)] } ] end |