Sha256: 8015a69c7082f695454b11276989e946ae1c54c6bb9048b424ef3ce8c0a015ec
Contents?: true
Size: 1023 Bytes
Versions: 1
Compression:
Stored size: 1023 Bytes
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 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
state_mate-0.0.6 | lib/state_mate/adapters.rb |