module Incline::Extensions::TimeZoneConverter

Patches the TimeZoneConverter to call super.

Public Class Methods

included(base) click to toggle source

Patches the TimeZoneConverter to call super.

# File lib/incline/extensions/time_zone_converter.rb, line 10
def self.included(base)
  base.class_eval do

    undef type_cast_from_user

    def type_cast_from_user(value)
      if value.is_a?(::Array)
        value.map { |v| type_cast_from_user(v) }
      else
        # Convert to time first.
        value = super

        # Then convert the time zone if necessary.
        if value.respond_to?(:in_time_zone)
          begin
            value.in_time_zone
          rescue ArgumentError
            nil
          end
        else
          nil
        end
      end
    end
  end
end

Public Instance Methods

type_cast_from_user(value) click to toggle source
Calls superclass method
# File lib/incline/extensions/time_zone_converter.rb, line 15
def type_cast_from_user(value)
  if value.is_a?(::Array)
    value.map { |v| type_cast_from_user(v) }
  else
    # Convert to time first.
    value = super

    # Then convert the time zone if necessary.
    if value.respond_to?(:in_time_zone)
      begin
        value.in_time_zone
      rescue ArgumentError
        nil
      end
    else
      nil
    end
  end
end