acts_as_expirable 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45f75fd75552f99c578b3da1af5ca12835d028b2
4
- data.tar.gz: ede4bdd74972e87c869d509d71d816bbe8bcf4b4
3
+ metadata.gz: 0fdf6a76474815497492290af24f3f900907cf5f
4
+ data.tar.gz: 893dc4aa66d73188c51d68029050dd3ac40e4e9f
5
5
  SHA512:
6
- metadata.gz: 9da3266d44de4c31fc8a607ab4af0119cf1b77ea6616df8aa7a3a57d2d8086a3074621034dadb662d2c0e3d97ca90b2acd74e5632b349d0a3cc7e07393c0bdbb
7
- data.tar.gz: 12f5cea4de035042e16a6dad5aa1c6c16c05a8d287761520eec94f6122452d7aaef22387c9140f54e42a5fec71451050380a8f8287c333e6890406808422a4b0
6
+ metadata.gz: 93973f0d790aa33efff6e67dd2e1d5a8168d4267a346544069fa4408ab72de255aeadcf0280356d1bd14adc0b83af5db96dac1359a85289a5b64f765c3c5c769
7
+ data.tar.gz: 556842f38439a63caea40fcdd2990a57048f877c99fc1421e272229ee2e484c9343d5364c5906bf15a38e4920351b816d747284c84c5413f61437c212cb4d8f7
@@ -18,7 +18,6 @@ module ActsAsExpirable
18
18
  class_attribute :acts_as_expirable_configuration
19
19
  scope :expired, -> { where(["#{acts_as_expirable_configuration[:column]} <= ?", Time.now]) }
20
20
  scope :unexpired, -> { where(["#{acts_as_expirable_configuration[:column]} IS NULL OR #{acts_as_expirable_configuration[:column]} > ?", Time.now]) }
21
- delegate :expiry_column, to: :class
22
21
  before_validation :set_expiry_default, on: :create
23
22
  end
24
23
 
@@ -36,16 +35,20 @@ module ActsAsExpirable
36
35
  end
37
36
  end
38
37
 
38
+ def expiry_column
39
+ self.class.expiry_column
40
+ end
41
+
39
42
  def expire
40
- write_attribute(self.class.expiry_column, Time.now)
43
+ write_attribute(expiry_column, Time.now)
41
44
  end
42
45
 
43
46
  def expire!
44
- update_attribute(self.class.expiry_column, Time.now)
47
+ update_attribute(expiry_column, Time.now)
45
48
  end
46
49
 
47
50
  def expired?
48
- expire_time = read_attribute(self.class.expiry_column)
51
+ expire_time = read_attribute(expiry_column)
49
52
  return false if expire_time.nil?
50
53
  expire_time <= Time.now
51
54
  end
@@ -1,6 +1,6 @@
1
1
  module ActsAsExpirable
2
2
  MAJOR = 0
3
3
  MINOR = 1
4
- BUILD = 0
4
+ BUILD = 1
5
5
  VERSION = [MAJOR, MINOR, BUILD].join(".")
6
6
  end
@@ -33,11 +33,11 @@ class ExpirableTest < Test::Unit::TestCase
33
33
  assert (Time.now.to_i + 1.day) - token.good_until.to_i <= 1, "should be set to nowish"
34
34
  end
35
35
 
36
- def test_expired
36
+ def test_expired_scope
37
37
  assert_equal(1, ExpirableName.expired.count)
38
38
  end
39
39
 
40
- def test_unexpired
40
+ def test_unexpired_scope
41
41
  assert_equal(2, ExpirableName.unexpired.count)
42
42
  end
43
43
 
@@ -84,4 +84,4 @@ class ExpirableTest < Test::Unit::TestCase
84
84
  assert name.expired?
85
85
  end
86
86
 
87
- end
87
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_expirable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Ching