Sha256: f1e046b371d93ac96e075f0113d5707cf2b075a869a3833de89516d48b0ed6ac

Contents?: true

Size: 860 Bytes

Versions: 1

Compression:

Stored size: 860 Bytes

Contents

module Daijobu

  # The Scheme module is the parent of the various serialization schemes.
  module Scheme
    
    # Given a name, returns a new instance of the corresponding scheme.
    #
    #   :marshal  => Daijobu::Scheme::Marshal
    #   :json     => Daijobu::Scheme::JSON
    #   :yaml     => Daijobu::Scheme::YAML
    #   :eval     => Daijobu::Scheme::Eval
    #   :raw      => Daijobu::Scheme::Raw
    #
    # Raises Daijobu::UnknownScheme if given a name it can't handle. 
    def self.get(name)
      case name
      when :marshal
        Daijobu::Scheme::Marshal.new
      when :json
        Daijobu::Scheme::JSON.new
      when :yaml
        Daijobu::Scheme::YAML.new
      when :eval
        Daijobu::Scheme::Eval.new
      when :raw
        Daijobu::Scheme::Raw.new
      else
        raise Daijobu::UnknownScheme
      end
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sander6-daijobu-0.2.1 lib/daijobu/scheme.rb