Sha256: 81585b2358e4856c5cd838626ca6c567aa2e935a88e157435531c570f449d7ee

Contents?: true

Size: 1.02 KB

Versions: 133

Compression:

Stored size: 1.02 KB

Contents

require 'active_support/time'

module Oj

  # Exists only to handle the ActiveSupport::TimeWithZone.
  class ActiveSupportHelper

    def self.createTimeWithZone(utc, zone)
      ActiveSupport::TimeWithZone.new(utc - utc.gmt_offset, ActiveSupport::TimeZone[zone])
    end
  end

end

Oj.register_odd(ActiveSupport::TimeWithZone, Oj::ActiveSupportHelper, :createTimeWithZone, :utc, 'time_zone.name')

# This is a hack to work around an oddness with DateTime and the ActiveSupport
# that causes a hang when some methods are called from C. Hour, min(ute),
# sec(ond) and other methods are special but they can be called from C until
# activesupport/time is required. After that they can not be even though
# resond_to? returns true. By defining methods to call super the problem goes
# away. There is obviously some magic going on under the covers that I don't
# understand.
class DateTime
  def hour()
    super
  end
  def min()
    super
  end
  def sec()
    super
  end
  def sec_fraction()
    super
  end
  def offset()
    super
  end
end

Version data entries

133 entries across 133 versions & 3 rubygems

Version Path
devcycle-ruby-server-sdk-2.0.0 vendor/bundle/ruby/3.0.0/gems/oj-3.13.2/lib/oj/active_support_helper.rb
oj-3.14.2 lib/oj/active_support_helper.rb
oj-3.14.1 lib/oj/active_support_helper.rb
oj-3.14.0 lib/oj/active_support_helper.rb
oj-3.13.23 lib/oj/active_support_helper.rb
oj-3.13.22 lib/oj/active_support_helper.rb
oj-3.13.21 lib/oj/active_support_helper.rb
oj-3.13.20 lib/oj/active_support_helper.rb
oj-3.13.19 lib/oj/active_support_helper.rb
oj-3.13.18 lib/oj/active_support_helper.rb
oj-3.13.17 lib/oj/active_support_helper.rb
oj-3.13.16 lib/oj/active_support_helper.rb
oj-3.13.15 lib/oj/active_support_helper.rb
oj-3.13.14 lib/oj/active_support_helper.rb
oj-3.13.13 lib/oj/active_support_helper.rb
oj-3.13.12 lib/oj/active_support_helper.rb
oj-3.13.11 lib/oj/active_support_helper.rb
oj-3.13.10 lib/oj/active_support_helper.rb
oj-3.13.9 lib/oj/active_support_helper.rb
oj-3.13.8 lib/oj/active_support_helper.rb