In Files
- psych/lib/psych/coder.rb
Parent
Class/Module Index
- Kernel
- Module
- Object
- Psych
- Psych::BadAlias
- Psych::ClassLoader
- Psych::ClassLoader::Restricted
- Psych::Coder
- Psych::DisallowedClass
- Psych::Emitter
- Psych::Exception
- Psych::Handler
- Psych::Handler::DumperOptions
- Psych::Handlers
- Psych::Handlers::Recorder
- Psych::JSON
- Psych::JSON::Stream
- Psych::JSON::TreeBuilder
- Psych::Nodes
- Psych::Nodes::Alias
- Psych::Nodes::Document
- Psych::Nodes::Mapping
- Psych::Nodes::Node
- Psych::Nodes::Scalar
- Psych::Nodes::Sequence
- Psych::Nodes::Stream
- Psych::Omap
- Psych::Parser
- Psych::Parser::Mark
- Psych::ScalarScanner
- Psych::Set
- Psych::Stream
- Psych::Streaming
- Psych::Streaming::ClassMethods
- Psych::SyntaxError
- Psych::TreeBuilder
- Psych::Visitors
- Psych::Visitors::DepthFirst
- Psych::Visitors::Emitter
- Psych::Visitors::JSONTree
- Psych::Visitors::NoAliasRuby
- Psych::Visitors::ToRuby
- Psych::Visitors::Visitor
- Psych::Visitors::YAMLTree
- Regexp
Psych::Coder
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.
Public Class Methods
Public Instance Methods
[]=(k, v)
# File psych/lib/psych/coder.rb, line 78 def []= k, v @type = :map @map[k] = v end
Also aliased as: add
map(tag = @tag, style = @style)
Emit a map. The coder will be yielded to the block.
# File psych/lib/psych/coder.rb, line 34 def map tag = @tag, style = @style @tag = tag @style = style yield self if block_given? @map end
map=(map)
Emit a map with value
# File psych/lib/psych/coder.rb, line 73 def map= map @type = :map @map = map end
represent_map(tag, map)
Emit a sequence with map
and tag
# File psych/lib/psych/coder.rb, line 54 def represent_map tag, map @tag = tag self.map = map end
represent_object(tag, obj)
Emit an arbitrary object obj
and tag
# File psych/lib/psych/coder.rb, line 60 def represent_object tag, obj @tag = tag @type = :object @object = obj end
represent_scalar(tag, value)
Emit a scalar with value
and tag
# File psych/lib/psych/coder.rb, line 42 def represent_scalar tag, value self.tag = tag self.scalar = value end
represent_seq(tag, list)
Emit a sequence with list
and tag
# File psych/lib/psych/coder.rb, line 48 def represent_seq tag, list @tag = tag self.seq = list end
scalar(*args)
# File 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