Class: TimeCamp::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-timecamp/resource.rb

Direct Known Subclasses

Entry, Task, Timer, User

Class Method Summary collapse

Instance Method Summary collapse

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_nameObject

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

#attributesObject

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