module UserTimezone::DetectsTimezone::ClassMethods

Public Instance Methods

detects_timezone(options = {}) click to toggle source
# File lib/user_timezone/detects_timezone.rb, line 8
def detects_timezone(options = {})
  cattr_accessor :timezone_detector
  self.timezone_detector = UserTimezone::TimezoneDetector.new(options)
  include LocalInstanceMethods
  case options[:on]
    when :before_save
      before_save :detect_timezone!
    when :before_create
      before_create :detect_timezone!
    else
      # Do nothing, but using switch statement
  end
end