Public Instance methods
eval_inspect(obj)
Special case objects where inspect does not generally produce input suitable for eval. Used by Sequel::SQL::Expression#inspect so that it can produce a string suitable for eval even if components of the expression have inspect methods that do not produce strings suitable for eval.
[show source]
# File lib/sequel/extensions/eval_inspect.rb 27 def eval_inspect(obj) 28 case obj 29 when BigDecimal 30 "Kernel::BigDecimal(#{obj.to_s.inspect})" 31 when Sequel::SQL::Blob, Sequel::LiteralString 32 "#{obj.class}.new(#{obj.to_s.inspect})" 33 when Sequel::SQL::ValueList 34 "#{obj.class}.new(#{obj.to_a.inspect})" 35 when Array 36 "[#{obj.map{|o| eval_inspect(o)}.join(', ')}]" 37 when Set 38 "Set[#{obj.map{|o| eval_inspect(o)}.join(', ')}]" 39 when Hash 40 "{#{obj.map{|k, v| "#{eval_inspect(k)} => #{eval_inspect(v)}"}.join(', ')}}" 41 when Time 42 datepart = "%Y-%m-%dT" unless obj.is_a?(Sequel::SQLTime) 43 "#{obj.class}.parse(#{obj.strftime("#{datepart}%T.%N%z").inspect})#{'.utc' if obj.utc?}" 44 when DateTime 45 # Ignore date of calendar reform 46 "DateTime.parse(#{obj.strftime('%FT%T.%N%z').inspect})" 47 when Date 48 # Ignore offset and date of calendar reform 49 "Date.new(#{obj.year}, #{obj.month}, #{obj.day})" 50 else 51 obj.inspect 52 end 53 end