1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add :encode_with for proper YAML serialization

This commit is contained in:
Ivan Antropov 2013-11-09 10:16:19 +07:00
parent 9e53488b1d
commit fcb00d388c
2 changed files with 12 additions and 0 deletions

View file

@ -5,6 +5,10 @@ module Arel
include Arel::Predications
include Arel::AliasPredication
include Arel::OrderPredications
def encode_with(coder)
coder.scalar = self.to_s
end
end
class BindParam < SqlLiteral

View file

@ -1,4 +1,5 @@
require 'helper'
require 'yaml'
module Arel
module Nodes
@ -56,6 +57,13 @@ module Arel
@visitor.accept(node).must_be_like %{ (foo = 1 AND foo = 2) }
end
end
describe 'serialization' do
it 'serializes into YAML' do
yaml_literal = SqlLiteral.new('foo').to_yaml
assert_equal('foo', YAML.load(yaml_literal))
end
end
end
end
end