time_for_a_boolean 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 277793114b162bb1a4753e9400c14ae68708e217
4
- data.tar.gz: 5eae5941a38459c5a383dd8eb4561a8d839eb7e2
3
+ metadata.gz: 30d3d6fb61fadfe42cb1b68e28ee31febc5c14db
4
+ data.tar.gz: 3413a70030888435ed32146dba0e8e3ddc379560
5
5
  SHA512:
6
- metadata.gz: d084a3437da16608c2539cd5b8d9f11e6b0e5f1d0956c6d77c84aa15ee3f7cfde0bb3934ebf3d96ea3d70cd072e6deef1ffb781b225a2b29e3a668a575f77228
7
- data.tar.gz: dfdc83188a96c03337bd9dbcef49700c2e15772703dfdbdb61087d193e59889965768fb184c217dd041a029248b309bc03ad1c062d2c8c45bb53e8b5989dbebb
6
+ metadata.gz: 8ce3a5d10696968948d50b41e3762e2afd698987439a5c7ac58b6c8b268f9d806cb0fefdafb6d84c40255220add9e659a64c5f1e622d2f66b9b7a843ab288854
7
+ data.tar.gz: 8ef16ab77d836e6fb0ca32871c6f70f68f99366abd9a6f9720d7e359a9acecab1b0a7a845dc9f42d6766dcf6d4bdfe7966df2d783f56d994bd128412d36e5546
data/README.md CHANGED
@@ -63,9 +63,9 @@ methods are defined:
63
63
 
64
64
  | Method | Description
65
65
  | --------------- | -----------
66
- | `Post#deleted` | `true` if `Post#deleted_at` is set, `false` otherwise
66
+ | `Post#deleted` | `true` if `Post#deleted_at` is set to a value greater than `Time.current`, `false` otherwise
67
67
  | `Post#deleted?` | Alias for `Post#deleted`
68
- | `Post#deleted=` | Sets the timestamp to `DateTime.now` if the new value is true, and `nil` otherwise
68
+ | `Post#deleted=` | Sets the timestamp to `Time.current` if the new value is true, and `nil` otherwise
69
69
 
70
70
  These methods allow you to use a timestamp as you would a boolean value in your
71
71
  application.
@@ -6,12 +6,12 @@ module TimeForABoolean
6
6
  def time_for_a_boolean(attribute)
7
7
  define_method(attribute) do
8
8
  !send("#{attribute}_at").nil? &&
9
- send("#{attribute}_at") <= -> { DateTime.current }.()
9
+ send("#{attribute}_at") <= -> { Time.current }.()
10
10
  end
11
11
  alias_method "#{attribute}?", attribute
12
12
  define_method("#{attribute}=") do |value|
13
13
  if ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(value)
14
- send("#{attribute}_at=", -> { DateTime.current }.())
14
+ send("#{attribute}_at=", -> { Time.current }.())
15
15
  else
16
16
  send("#{attribute}_at=", nil)
17
17
  end
@@ -1,3 +1,3 @@
1
1
  module TimeForABoolean
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -35,7 +35,7 @@ describe TimeForABoolean do
35
35
 
36
36
  it 'is true if the attribute is not nil' do
37
37
  klass.time_for_a_boolean :attribute
38
- allow(object).to receive(:attribute_at).and_return(DateTime.now - 10)
38
+ allow(object).to receive(:attribute_at).and_return(Time.now - 10)
39
39
 
40
40
  expect(object.attribute).to be_truthy
41
41
  end
@@ -70,14 +70,14 @@ describe TimeForABoolean do
70
70
 
71
71
  object.attribute = true
72
72
 
73
- expect(object.attribute_at).to be_kind_of(DateTime)
73
+ expect(object.attribute_at).to be_kind_of(Time)
74
74
  end
75
75
 
76
76
  it 'sets the timestamp to nil if value is false' do
77
77
  klass.time_for_a_boolean :attribute
78
78
  klass.send(:attr_accessor, :attribute_at)
79
79
 
80
- object.attribute_at = DateTime.now
80
+ object.attribute_at = Time.now
81
81
  object.attribute = false
82
82
 
83
83
  expect(object.attribute_at).to be_nil
@@ -89,14 +89,14 @@ describe TimeForABoolean do
89
89
 
90
90
  object.attribute = '1'
91
91
 
92
- expect(object.attribute_at).to be_kind_of(DateTime)
92
+ expect(object.attribute_at).to be_kind_of(Time)
93
93
  end
94
94
 
95
95
  it 'works with other representations of false' do
96
96
  klass.time_for_a_boolean :attribute
97
97
  klass.send(:attr_accessor, :attribute_at)
98
98
 
99
- object.attribute_at = DateTime.now
99
+ object.attribute_at = Time.now
100
100
  object.attribute = '0'
101
101
 
102
102
  expect(object.attribute_at).to be_nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time_for_a_boolean
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caleb Thompson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-31 00:00:00.000000000 Z
11
+ date: 2014-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails