Sha256: 5c9012f785c54529abe58752b8884f9a2d0d2d1e7e5553fe8785271bf0d220c1
Contents?: true
Size: 1013 Bytes
Versions: 2
Compression:
Stored size: 1013 Bytes
Contents
require 'active_support/all' class FalseClass def to_builder 'false' end end class TrueClass def to_builder 'true' end end class String JS_ESCAPE_MAP = { '\\' => '\\\\', '</' => '<\/', "\r\n" => '\n', "\n" => '\n', "\r" => '\n', '"' => '\\"', "'" => "\\'" } def to_builder %("#{json_escape}") end private def json_escape gsub(/(\\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"'])/u) { |match| JS_ESCAPE_MAP[match] } end end class Hash def to_builder to_json end end class NilClass def to_builder 'null' end end module ActiveSupport class TimeWithZone def to_builder %("#{iso8601}") end end end class Time def to_builder %("#{iso8601}") end end class Date def to_builder %("#{to_time.iso8601}") end end class DateTime def to_builder %("#{to_time.iso8601}") end end module BSON class ObjectId def to_builder %("#{self}") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
json_builder-3.1.4 | lib/json_builder/extensions.rb |
json_builder-3.1.3 | lib/json_builder/extensions.rb |