reviewed 0.1.28 → 0.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/reviewed/base.rb +16 -0
- data/lib/reviewed/version.rb +1 -1
- data/spec/base_spec.rb +14 -2
- metadata +1 -1
data/lib/reviewed/base.rb
CHANGED
@@ -12,6 +12,22 @@ module Reviewed
|
|
12
12
|
self.attributes = objectify(data)
|
13
13
|
end
|
14
14
|
|
15
|
+
def created_at
|
16
|
+
if @attributes.has_key?(:created_at)
|
17
|
+
Time.parse(@attributes[:created_at])
|
18
|
+
else
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def updated_at
|
24
|
+
if @attributes.has_key?(:updated_at)
|
25
|
+
Time.parse(@attributes[:updated_at])
|
26
|
+
else
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
15
31
|
class << self
|
16
32
|
|
17
33
|
def path
|
data/lib/reviewed/version.rb
CHANGED
data/spec/base_spec.rb
CHANGED
@@ -41,9 +41,21 @@ describe Reviewed::Base do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
describe 'attributes' do
|
44
|
+
before(:each) do
|
45
|
+
@timestamp = Time.parse("01/01/2013 10:00:00 GMT")
|
46
|
+
@model = Example.new(id: 'id', super_awesome: 'true', created_at: @timestamp.to_s, updated_at: @timestamp.to_s)
|
47
|
+
end
|
48
|
+
|
44
49
|
it 'returns the named attribute (via method missing)' do
|
45
|
-
model
|
46
|
-
|
50
|
+
@model.super_awesome.should == 'true'
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'has a created at timestamp' do
|
54
|
+
@model.created_at.should == @timestamp
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'has an updated at timestamp' do
|
58
|
+
@model.updated_at.should == @timestamp
|
47
59
|
end
|
48
60
|
end
|
49
61
|
|