Module: UserTimezone::DetectsTimezone::ClassMethods

Defined in:
lib/user_timezone/detects_timezone.rb

Instance Method Summary collapse

Instance Method Details

#detects_timezone(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# 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