act_as_time_as_boolean 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -29,13 +29,12 @@ protected
|
|
29
29
|
|
30
30
|
def self.field_setter_method(field)
|
31
31
|
self.send :define_method, :"#{field}=" do |value|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
32
|
+
value = value && value.to_s != '0'
|
33
|
+
if value && !self.send(field)
|
34
|
+
send :"#{field}_at=", Time.now
|
35
|
+
true
|
36
|
+
elsif !value && self.send(field)
|
37
|
+
send :"#{field}_at=", nil
|
39
38
|
end
|
40
39
|
end
|
41
40
|
end
|
@@ -98,6 +98,18 @@ describe ActAsTimeAsBoolean do
|
|
98
98
|
|
99
99
|
it { subject.active_at.should be_nil }
|
100
100
|
end
|
101
|
+
|
102
|
+
describe "with '1'" do
|
103
|
+
before { subject.active = '1' }
|
104
|
+
|
105
|
+
it { subject.active_at.should == time }
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "with '0'" do
|
109
|
+
before { subject.active = '0' }
|
110
|
+
|
111
|
+
it { subject.active_at.should be_nil }
|
112
|
+
end
|
101
113
|
end
|
102
114
|
|
103
115
|
describe 'calling inactive' do
|
@@ -132,6 +144,18 @@ describe ActAsTimeAsBoolean do
|
|
132
144
|
|
133
145
|
it { subject.active_at.should be_nil }
|
134
146
|
end
|
147
|
+
|
148
|
+
describe "with '1'" do
|
149
|
+
before { subject.active = '1' }
|
150
|
+
|
151
|
+
it { subject.active_at.class.should == Time }
|
152
|
+
end
|
153
|
+
|
154
|
+
describe "with '0'" do
|
155
|
+
before { subject.active = '0' }
|
156
|
+
|
157
|
+
it { subject.active_at.should be_nil }
|
158
|
+
end
|
135
159
|
end
|
136
160
|
|
137
161
|
describe 'calling inactive' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: act_as_time_as_boolean
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06
|
12
|
+
date: 2013-12-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
117
|
rubyforge_project:
|
118
|
-
rubygems_version: 1.8.
|
118
|
+
rubygems_version: 1.8.26
|
119
119
|
signing_key:
|
120
120
|
specification_version: 3
|
121
121
|
summary: Add time_as_boolean feature to your ruby classes
|