summaryrefslogtreecommitdiff
path: root/ext/psych/lib/psych/coder.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/psych/lib/psych/coder.rb')
-rw-r--r--ext/psych/lib/psych/coder.rb24
1 files changed, 16 insertions, 8 deletions
diff --git a/ext/psych/lib/psych/coder.rb b/ext/psych/lib/psych/coder.rb
index c06c9c1e61..2b830d2b21 100644
--- a/ext/psych/lib/psych/coder.rb
+++ b/ext/psych/lib/psych/coder.rb
@@ -6,17 +6,18 @@ module Psych
# objects like Sequence and Scalar may be emitted if +seq=+ or +scalar=+ are
# called, respectively.
class Coder
- attr_accessor :tag, :style, :implicit
+ attr_accessor :tag, :style, :implicit, :object
attr_reader :type, :seq
def initialize tag
- @map = {}
- @seq = []
- @implicit = false
- @type = :map
- @tag = tag
- @style = Psych::Nodes::Mapping::BLOCK
- @scalar = nil
+ @map = {}
+ @seq = []
+ @implicit = false
+ @type = :map
+ @tag = tag
+ @style = Psych::Nodes::Mapping::BLOCK
+ @scalar = nil
+ @object = nil
end
def scalar *args
@@ -54,6 +55,13 @@ module Psych
self.map = map
end
+ # Emit an arbitrary object +obj+ and +tag+
+ def represent_object tag, obj
+ @tag = tag
+ @type = :object
+ @object = obj
+ end
+
# Emit a scalar with +value+
def scalar= value
@type = :scalar