Sha256: 919b39bb0e1f4a0f0e85b645f8fd1c620b696dec195ee62cec9774cf1c66c5d6
Contents?: true
Size: 1.06 KB
Versions: 3
Compression:
Stored size: 1.06 KB
Contents
require 'pp' module StateMate; end module StateMate::Adapters API_METHOD_NAMES = [:read, :write] @@index = {} module IncludeClassMethods def register name StateMate::Adapters.register name, self end end def self.included base base.extend IncludeClassMethods end def self.register name, obj unless name.is_a? String raise StateMate::Error::TypeError.new name, "name must be a String" end @@index[name] = obj end def self.get name # return it if it's already loaded return @@index[name] if @@index.key? name # try to require it begin require "state_mate/adapters/#{ name }" rescue LoadError => e StateMate.debug "failed to require adapter #{ name }", e end unless @@index.key? name raise StateMate::Error::AdapterNotFoundError.new NRSER.dedent <<-END adapter #{ name.inspect } was not found. registered adapters: #{ @@index.pretty_inspect } END end @@index[name] end end # Adapters
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
state_mate-0.0.9 | lib/state_mate/adapters.rb |
state_mate-0.0.8 | lib/state_mate/adapters.rb |
state_mate-0.0.7 | lib/state_mate/adapters.rb |