Class
If an object defines encode_with
, then an instance of Psych::Coder
will be passed to the method when the object is being serialized. The Coder
automatically assumes a Psych::Nodes::Mapping
is being emitted. Other objects like Sequence and Scalar may be emitted if seq=
or scalar=
are called, respectively.
Attributes
Read & Write
No documentation available
Read & Write
No documentation available
Read & Write
No documentation available
Read & Write
No documentation available
Read
No documentation available
Read
No documentation available
Class Methods
::
ext/psych/lib/psych/coder.rb
View on GitHub
# File tmp/rubies/ruby-2.3.8/ext/psych/lib/psych/coder.rb, line 13
def initialize tag
@map = {}
@seq = []
@implicit = false
@type = :map
@tag = tag
@style = Psych::Nodes::Mapping::BLOCK
@scalar = nil
@object = nil
end
No documentation available
Instance Methods
#
ext/psych/lib/psych/coder.rb
View on GitHub
# File tmp/rubies/ruby-2.3.8/ext/psych/lib/psych/coder.rb, line 84
def [] k
@type = :map
@map[k]
end
No documentation available
ext/psych/lib/psych/coder.rb
View on GitHub
# File tmp/rubies/ruby-2.3.8/ext/psych/lib/psych/coder.rb, line 78
def []= k, v
@type = :map
@map[k] = v
end
No documentation available
ext/psych/lib/psych/coder.rb
View on GitHub
# File tmp/rubies/ruby-2.3.8/ext/psych/lib/psych/coder.rb, line 34
def map tag = @tag, style = @style
@tag = tag
@style = style
yield self if block_given?
@map
end
Emit a map. The coder will be yielded to the block.
ext/psych/lib/psych/coder.rb
View on GitHub
# File tmp/rubies/ruby-2.3.8/ext/psych/lib/psych/coder.rb, line 73
def map= map
@type = :map
@map = map
end
Emit a map with value
ext/psych/lib/psych/coder.rb
View on GitHub
# File tmp/rubies/ruby-2.3.8/ext/psych/lib/psych/coder.rb, line 54
def represent_map tag, map
@tag = tag
self.map = map
end
Emit a sequence with map
and tag
ext/psych/lib/psych/coder.rb
View on GitHub
# File tmp/rubies/ruby-2.3.8/ext/psych/lib/psych/coder.rb, line 60
def represent_object tag, obj
@tag = tag
@type = :object
@object = obj
end
Emit an arbitrary object obj
and tag
ext/psych/lib/psych/coder.rb
View on GitHub
# File tmp/rubies/ruby-2.3.8/ext/psych/lib/psych/coder.rb, line 42
def represent_scalar tag, value
self.tag = tag
self.scalar = value
end
Emit a scalar with value
and tag
ext/psych/lib/psych/coder.rb
View on GitHub
# File tmp/rubies/ruby-2.3.8/ext/psych/lib/psych/coder.rb, line 48
def represent_seq tag, list
@tag = tag
self.seq = list
end
Emit a sequence with list
and tag
ext/psych/lib/psych/coder.rb
View on GitHub
# File tmp/rubies/ruby-2.3.8/ext/psych/lib/psych/coder.rb, line 24
def scalar *args
if args.length > 0
warn "#{caller[0]}: Coder#scalar(a,b,c) is deprecated" if $VERBOSE
@tag, @scalar, _ = args
@type = :scalar
end
@scalar
end
No documentation available
ext/psych/lib/psych/coder.rb
View on GitHub
# File tmp/rubies/ruby-2.3.8/ext/psych/lib/psych/coder.rb, line 67
def scalar= value
@type = :scalar
@scalar = value
end
Emit a scalar with value
ext/psych/lib/psych/coder.rb
View on GitHub
# File tmp/rubies/ruby-2.3.8/ext/psych/lib/psych/coder.rb, line 90
def seq= list
@type = :seq
@seq = list
end
Emit a sequence of list