Class: Freckle::Base
- Inherits:
-
Object
show all
- Includes:
- Comparable
- Defined in:
- lib/freckle.rb
Overview
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(attributes, connection = nil) ⇒ Base
Returns a new instance of Base.
61
62
63
64
|
# File 'lib/freckle.rb', line 61
def initialize(attributes, connection = nil)
@connection = connection
@attributes = attributes
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
68
69
70
71
|
# File 'lib/freckle.rb', line 68
def method_missing(method_name, *args)
return @attributes[method_name.to_s] if @attributes.key?(method_name.to_s)
super
end
|
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
60
61
62
|
# File 'lib/freckle.rb', line 60
def attributes
@attributes
end
|
Class Method Details
.all(key = nil, options = {}) ⇒ Object
72
73
74
75
|
# File 'lib/freckle.rb', line 72
def self.all(key = nil, options = {})
raise ArgumentError, "key is required" if key.nil?
Freckle.connection.send(key, options)
end
|
.first(options = {}) ⇒ Object
76
77
78
|
# File 'lib/freckle.rb', line 76
def self.first(options = {})
self.all(options).first
end
|
Instance Method Details
#<=>(other) ⇒ Object
79
80
81
|
# File 'lib/freckle.rb', line 79
def <=>(other)
[self.class, self.id] <=> [other.class, other.id]
end
|
#id ⇒ Object
65
66
67
|
# File 'lib/freckle.rb', line 65
def id
@attributes['id']
end
|