Sha256: e2d6b27e7488117de3364fa6f9c30641255e4a7a287cbb755628361f3ae8ba03
Contents?: true
Size: 1009 Bytes
Versions: 1
Compression:
Stored size: 1009 Bytes
Contents
module Daijobu class SchemeSet DEFAULT = [ :marshal, :json, :yaml, :eval ] attr_reader :current def initialize(schemes = nil) schemes = Array(schemes) schemes = DEFAULT if schemes.empty? @schemes = schemes.collect { |scheme| Daijobu::Scheme.get(scheme) } @current = 0 end def next scheme = @schemes[@current] raise NoFallbackScheme unless scheme @current += 1 return scheme end def reset @current = 0 end def parse(str) begin obj = self.next.parse(str) rescue => e if e.kind_of?(Daijobu::Error) raise e else obj = parse(str) end end self.reset obj end def unparse(obj) begin str = self.next.unparse(obj) rescue => e if e.kind_of?(Daijobu::Error) raise e else str = unparse(str) end end self.reset str end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sander6-daijobu-0.2.0 | lib/daijobu/scheme_set.rb |