Sha256: f93358f450d71f703018dde67c1963a1fd8cddff2ebd2e9ef9f4fd4aea95ecfb
Contents?: true
Size: 960 Bytes
Versions: 2
Compression:
Stored size: 960 Bytes
Contents
module Daijobu class SchemeSet DEFAULT = [ :marshal, :json, :yaml, :eval ] attr_reader :current def initialize(*schemes) @schemes = (schemes.empty? ? DEFAULT : 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sander6-daijobu-0.1.0 | lib/daijobu/scheme_set.rb |
sander6-daijobu-0.1.1 | lib/daijobu/scheme_set.rb |