active_regulation 2.2.2 → 2.2.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9aa82e0167349adfbb84e128be29ebad0150e584
|
4
|
+
data.tar.gz: 156553f7a81734974ebdc1e364f5280a3538b96c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba24e5cc07a65277486d020ad1a3c23857e59eaa2a8327a4c29df1e9968513525d01340ed410ca7bfb484d5e8838d0e51c4c2911e89b14581dca13edd1993ade
|
7
|
+
data.tar.gz: a7555820016dfd810d44b80a7ff98cb92a9d32bc357743b7cb88a563c7b054e72bc93767b511ce5cc40b43d70d30542fa761226fe1d14ad677d3bde1a5c8b0cb
|
@@ -3,13 +3,10 @@ module ActiveRegulation
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
attr_accessor :activation
|
6
|
+
attr_accessor :activation, :raw_activation
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
allow_nil: true
|
11
|
-
|
12
|
-
before_save :record_activation!
|
8
|
+
before_save :record_activation!, unless: -> (obj) { obj.raw_activation.nil? }
|
9
|
+
after_initialize :set_activation!
|
13
10
|
|
14
11
|
scope :active, -> { where(inactivated_at: nil) }
|
15
12
|
scope :inactive, -> { where.not(inactivated_at: nil) }
|
@@ -38,7 +35,20 @@ module ActiveRegulation
|
|
38
35
|
private
|
39
36
|
|
40
37
|
def record_activation!
|
41
|
-
|
38
|
+
false_value = ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.include?(activation)
|
39
|
+
true_value = ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(activation)
|
40
|
+
|
41
|
+
if false_value || true_value
|
42
|
+
self.inactivated_at = (false_value ? Time.now : nil)
|
43
|
+
else
|
44
|
+
raise ArgumentError,
|
45
|
+
"Unknown boolean: #{activation.inspect}. Must be a valid boolean."
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def set_activation!
|
50
|
+
self.raw_activation = activation
|
51
|
+
self.activation = active? if activation.nil?
|
42
52
|
end
|
43
53
|
|
44
54
|
end
|
@@ -3,13 +3,10 @@ module ActiveRegulation
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
attr_accessor :containment
|
6
|
+
attr_accessor :containment, :raw_containment
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
allow_nil: true
|
11
|
-
|
12
|
-
before_save :record_containment!
|
8
|
+
before_save :record_containment!, unless: -> (obj) { obj.raw_containment.nil? }
|
9
|
+
after_initialize :set_containment!
|
13
10
|
|
14
11
|
scope :contained, -> { where.not(contained_at: nil) }
|
15
12
|
scope :uncontained, -> { where(contained_at: nil) }
|
@@ -38,7 +35,20 @@ module ActiveRegulation
|
|
38
35
|
private
|
39
36
|
|
40
37
|
def record_containment!
|
41
|
-
|
38
|
+
false_value = ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.include?(containment)
|
39
|
+
true_value = ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(containment)
|
40
|
+
|
41
|
+
if false_value || true_value
|
42
|
+
self.contained_at = (false_value ? nil : Time.now)
|
43
|
+
else
|
44
|
+
raise ArgumentError,
|
45
|
+
"Unknown boolean: #{containment.inspect}. Must be a valid boolean."
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def set_containment!
|
50
|
+
self.raw_containment = containment
|
51
|
+
self.containment = contained? if containment.nil?
|
42
52
|
end
|
43
53
|
|
44
54
|
end
|
@@ -5,13 +5,10 @@ module ActiveRegulation
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
-
attr_accessor :expiration
|
8
|
+
attr_accessor :expiration, :raw_expiration
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
allow_nil: true
|
13
|
-
|
14
|
-
before_save :record_expiration!
|
10
|
+
before_save :record_expiration!, unless: -> (obj) { obj.raw_expiration.nil? }
|
11
|
+
after_initialize :set_expiration!
|
15
12
|
|
16
13
|
scope :expired, -> { where("expires_at IS NULL OR expires_at < ?", Time.now) }
|
17
14
|
scope :unexpired, -> { where("expires_at IS NOT NULL AND expires_at >= ?", Time.now) }
|
@@ -48,7 +45,20 @@ module ActiveRegulation
|
|
48
45
|
end
|
49
46
|
|
50
47
|
def record_expiration!
|
51
|
-
|
48
|
+
false_value = ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.include?(expiration)
|
49
|
+
true_value = ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(expiration)
|
50
|
+
|
51
|
+
if false_value || true_value
|
52
|
+
self.expires_at = (false_value ? extension_date : nil)
|
53
|
+
else
|
54
|
+
raise ArgumentError,
|
55
|
+
"Unknown boolean: #{expiration.inspect}. Must be a valid boolean."
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def set_expiration!
|
60
|
+
self.raw_expiration = expiration
|
61
|
+
self.expiration = expired? if expiration.nil?
|
52
62
|
end
|
53
63
|
|
54
64
|
end
|
@@ -3,13 +3,10 @@ module ActiveRegulation
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
attr_accessor :visibility
|
6
|
+
attr_accessor :visibility, :raw_visibility
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
allow_nil: true
|
11
|
-
|
12
|
-
before_save :record_visibility!
|
8
|
+
before_save :record_visibility!, unless: -> (obj) { obj.raw_visibility.nil? }
|
9
|
+
after_initialize :set_visibility!
|
13
10
|
|
14
11
|
scope :visible, -> { where(invisible_at: nil) }
|
15
12
|
scope :invisible, -> { where.not(invisible_at: nil) }
|
@@ -38,7 +35,20 @@ module ActiveRegulation
|
|
38
35
|
private
|
39
36
|
|
40
37
|
def record_visibility!
|
41
|
-
|
38
|
+
false_value = ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.include?(visibility)
|
39
|
+
true_value = ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(visibility)
|
40
|
+
|
41
|
+
if false_value || true_value
|
42
|
+
self.invisible_at = (false_value ? Time.now : nil)
|
43
|
+
else
|
44
|
+
raise ArgumentError,
|
45
|
+
"Unknown boolean: #{visibility.inspect}. Must be a valid boolean."
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def set_visibility!
|
50
|
+
self.raw_visibility = visibility
|
51
|
+
self.visibility = visible? if visibility.nil?
|
42
52
|
end
|
43
53
|
|
44
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_regulation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|