lib/active_regulation/visibility.rb in active_regulation-2.2.3 vs lib/active_regulation/visibility.rb in active_regulation-2.2.4
- old
+ new
@@ -1,13 +1,14 @@
module ActiveRegulation
module Visibility
extend ActiveSupport::Concern
+ include ActiveRegulation::Base
included do
attr_accessor :visibility, :raw_visibility
- before_save :record_visibility!, unless: -> (obj) { obj.raw_visibility.nil? }
+ before_save :record_visibility!, unless: -> (obj) { obj.raw_visibility.nil? }
after_initialize :set_visibility!
scope :visible, -> { where(invisible_at: nil) }
scope :invisible, -> { where.not(invisible_at: nil) }
end
@@ -33,11 +34,11 @@
end
private
def record_visibility!
- false_value = ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.include?(visibility)
- true_value = ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(visibility)
+ false_value = FALSE_VALUES.include?(visibility)
+ true_value = TRUE_VALUES.include?(visibility)
if false_value || true_value
self.invisible_at = (false_value ? Time.now : nil)
else
raise ArgumentError,
\ No newline at end of file