active_regulation 2.2.3 → 2.2.4

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: 9aa82e0167349adfbb84e128be29ebad0150e584
4
- data.tar.gz: 156553f7a81734974ebdc1e364f5280a3538b96c
3
+ metadata.gz: 3fc2bb1f1f44100294643edca82dec9b0f6eb48f
4
+ data.tar.gz: 6e070d9bdb6c68e6bda282473b326682d74b0f88
5
5
  SHA512:
6
- metadata.gz: ba24e5cc07a65277486d020ad1a3c23857e59eaa2a8327a4c29df1e9968513525d01340ed410ca7bfb484d5e8838d0e51c4c2911e89b14581dca13edd1993ade
7
- data.tar.gz: a7555820016dfd810d44b80a7ff98cb92a9d32bc357743b7cb88a563c7b054e72bc93767b511ce5cc40b43d70d30542fa761226fe1d14ad677d3bde1a5c8b0cb
6
+ metadata.gz: 7e41be266892964af1cb98249892d7bacf44f0fd2bf957d94e7b3043ebba5c2770c21402ac46ca0b6da60fe3eaa0135552d51a6ed01382b2d6968cdd39cd78eb
7
+ data.tar.gz: 011b6671c3bac684868c5f128c69ae8a45caaf1029fb68ce563187055e6fee879ea609ba966ba0a6bcd3a1f3070c2d3cf4987950597c0cbfa0487f27e5002080
@@ -1,11 +1,12 @@
1
1
  module ActiveRegulation
2
2
  module Activation
3
3
  extend ActiveSupport::Concern
4
+ include ActiveRegulation::Base
4
5
 
5
6
  included do
6
7
  attr_accessor :activation, :raw_activation
7
8
 
8
- before_save :record_activation!, unless: -> (obj) { obj.raw_activation.nil? }
9
+ before_save :record_activation!, unless: -> (obj) { obj.raw_activation.nil? }
9
10
  after_initialize :set_activation!
10
11
 
11
12
  scope :active, -> { where(inactivated_at: nil) }
@@ -35,8 +36,8 @@ module ActiveRegulation
35
36
  private
36
37
 
37
38
  def record_activation!
38
- false_value = ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.include?(activation)
39
- true_value = ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(activation)
39
+ false_value = FALSE_VALUES.include?(activation)
40
+ true_value = TRUE_VALUES.include?(activation)
40
41
 
41
42
  if false_value || true_value
42
43
  self.inactivated_at = (false_value ? Time.now : nil)
@@ -0,0 +1,8 @@
1
+ module ActiveRegulation
2
+ module Base
3
+
4
+ FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE']
5
+ TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE']
6
+
7
+ end
8
+ end
@@ -1,11 +1,12 @@
1
1
  module ActiveRegulation
2
2
  module Containment
3
3
  extend ActiveSupport::Concern
4
+ include ActiveRegulation::Base
4
5
 
5
6
  included do
6
7
  attr_accessor :containment, :raw_containment
7
8
 
8
- before_save :record_containment!, unless: -> (obj) { obj.raw_containment.nil? }
9
+ before_save :record_containment!, unless: -> (obj) { obj.raw_containment.nil? }
9
10
  after_initialize :set_containment!
10
11
 
11
12
  scope :contained, -> { where.not(contained_at: nil) }
@@ -35,8 +36,8 @@ module ActiveRegulation
35
36
  private
36
37
 
37
38
  def record_containment!
38
- false_value = ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.include?(containment)
39
- true_value = ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(containment)
39
+ false_value = FALSE_VALUES.include?(containment)
40
+ true_value = TRUE_VALUES.include?(containment)
40
41
 
41
42
  if false_value || true_value
42
43
  self.contained_at = (false_value ? nil : Time.now)
@@ -3,11 +3,12 @@ require 'date'
3
3
  module ActiveRegulation
4
4
  module Expiration
5
5
  extend ActiveSupport::Concern
6
+ include ActiveRegulation::Base
6
7
 
7
8
  included do
8
9
  attr_accessor :expiration, :raw_expiration
9
10
 
10
- before_save :record_expiration!, unless: -> (obj) { obj.raw_expiration.nil? }
11
+ before_save :record_expiration!, unless: -> (obj) { obj.raw_expiration.nil? }
11
12
  after_initialize :set_expiration!
12
13
 
13
14
  scope :expired, -> { where("expires_at IS NULL OR expires_at < ?", Time.now) }
@@ -45,8 +46,8 @@ module ActiveRegulation
45
46
  end
46
47
 
47
48
  def record_expiration!
48
- false_value = ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.include?(expiration)
49
- true_value = ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(expiration)
49
+ false_value = FALSE_VALUES.include?(expiration)
50
+ true_value = TRUE_VALUES.include?(expiration)
50
51
 
51
52
  if false_value || true_value
52
53
  self.expires_at = (false_value ? extension_date : nil)
@@ -1,3 +1,3 @@
1
1
  module ActiveRegulation
2
- VERSION = "2.2.3"
2
+ VERSION = "2.2.4"
3
3
  end
@@ -1,11 +1,12 @@
1
1
  module ActiveRegulation
2
2
  module Visibility
3
3
  extend ActiveSupport::Concern
4
+ include ActiveRegulation::Base
4
5
 
5
6
  included do
6
7
  attr_accessor :visibility, :raw_visibility
7
8
 
8
- before_save :record_visibility!, unless: -> (obj) { obj.raw_visibility.nil? }
9
+ before_save :record_visibility!, unless: -> (obj) { obj.raw_visibility.nil? }
9
10
  after_initialize :set_visibility!
10
11
 
11
12
  scope :visible, -> { where(invisible_at: nil) }
@@ -35,8 +36,8 @@ module ActiveRegulation
35
36
  private
36
37
 
37
38
  def record_visibility!
38
- false_value = ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.include?(visibility)
39
- true_value = ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(visibility)
39
+ false_value = FALSE_VALUES.include?(visibility)
40
+ true_value = TRUE_VALUES.include?(visibility)
40
41
 
41
42
  if false_value || true_value
42
43
  self.invisible_at = (false_value ? Time.now : nil)
@@ -1,4 +1,5 @@
1
1
  require "active_regulation/version"
2
+ require "active_regulation/base"
2
3
  require "active_regulation/activation"
3
4
  require "active_regulation/containment"
4
5
  require "active_regulation/expiration"
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.3
4
+ version: 2.2.4
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-24 00:00:00.000000000 Z
11
+ date: 2015-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -144,6 +144,7 @@ files:
144
144
  - config/locales/en.yml
145
145
  - lib/active_regulation.rb
146
146
  - lib/active_regulation/activation.rb
147
+ - lib/active_regulation/base.rb
147
148
  - lib/active_regulation/containment.rb
148
149
  - lib/active_regulation/expiration.rb
149
150
  - lib/active_regulation/version.rb