Sha256: f3f2880b8bedb9fb65f7f5b4af3f47ee2ae2c43570c2e8d746e60149c19d1068

Contents?: true

Size: 661 Bytes

Versions: 11

Compression:

Stored size: 661 Bytes

Contents

require 'yaml'

module ASIR
  class Coder
    # !SLIDE
    # YAML Coder
    # Use YAML for encode/decode.
    class Yaml < self
      def _encode obj
        case obj
        when Message, Result
          obj = obj.encode_more!
        end
        ::YAML::dump(obj)
      rescue ::Exception
        require 'pp'
        msg = "#{self}: failed to encode: #{$!.inspect}:\n  #{PP.pp(obj, '')}"
        $stderr.puts msg
        raise Error, msg
      end

      def _decode obj
        case obj = ::YAML::load(obj)
        when Message, Result
          obj.decode_more!
        else
          obj
        end
      end
    end # class
  end # class
end # module

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
asir-1.1.3 lib/asir/coder/yaml.rb
asir-1.1.2 lib/asir/coder/yaml.rb
asir-1.1.1 lib/asir/coder/yaml.rb
asir-1.1.0 lib/asir/coder/yaml.rb
asir-1.0.8 lib/asir/coder/yaml.rb
asir-1.0.7 lib/asir/coder/yaml.rb
asir-1.0.6 lib/asir/coder/yaml.rb
asir-1.0.5 lib/asir/coder/yaml.rb
asir-1.0.4 lib/asir/coder/yaml.rb
asir-1.0.1 lib/asir/coder/yaml.rb
asir-0.2.0 lib/asir/coder/yaml.rb