Class: Sheep::Activity
- Inherits:
-
Object
show all
- Defined in:
- lib/sheep/activity.rb
Instance Method Summary
collapse
Constructor Details
#initialize(data) ⇒ Activity
Returns a new instance of Activity.
3
4
5
6
7
8
|
# File 'lib/sheep/activity.rb', line 3
def initialize(data)
@data = {}
data.each do |key, value|
self[key] = value
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(attribute, value = nil) ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/sheep/activity.rb', line 10
def method_missing(attribute, value = nil)
if attribute =~/\=$/
self[attribute.to_s.gsub(/\=$/, '')] = value
else
self[attribute]
end
end
|
Instance Method Details
#==(other) ⇒ Object
26
27
28
|
# File 'lib/sheep/activity.rb', line 26
def ==(other)
self.data == other.data
end
|
#[](attribute) ⇒ Object
18
19
20
|
# File 'lib/sheep/activity.rb', line 18
def [](attribute)
@data[attribute.to_s]
end
|
#[]=(attribute, value) ⇒ Object
22
23
24
|
# File 'lib/sheep/activity.rb', line 22
def []=(attribute, value)
@data[attribute.to_s] = value
end
|