module Activator

Constants

VERSION

Public Instance Methods

activator_deactivate!() click to toggle source
# File lib/activator.rb, line 40
def activator_deactivate!
  self.update_attributes(:"#{activator_field}" => false)
end

Private Instance Methods

activator_field() click to toggle source
# File lib/activator.rb, line 52
def activator_field
  self.class.used_activator_field
end
deactivate_others() click to toggle source
# File lib/activator.rb, line 45
def deactivate_others
  return unless self.send("#{activator_field}?".to_sym)
  self.class.where('id <> :id', id: self.id).
    where(:"#{activator_field}" => true).
    map(&:activator_deactivate!)
end