Sha256: a54e6ee1c3cfd0226ea2d59c86feb25f543e09bcfe2758d420a3212d68163559

Contents?: true

Size: 760 Bytes

Versions: 18

Compression:

Stored size: 760 Bytes

Contents

# Load each available adapter
require 'state_manager/adapters/base'
Dir["#{File.dirname(__FILE__)}/adapters/*.rb"].sort.each do |path|
  require "state_manager/adapters/#{File.basename(path)}"
end

module StateManager

  class AdapterNotFound < StandardError; end;

  module Adapters
    def self.match(klass)
      all.detect {|adapter| adapter.matches?(klass)}
    end

    def self.match_ancestors(ancestors)
      all.detect {|adapter| adapter.matches_ancestors?(ancestors)}
    end

    def self.find_by_name(name)
      all.detect {|adapter| adapter.integration_name == name} || raise(AdapterNotFound.new(name))
    end
    
    def self.all
      constants = self.constants.map {|c| c.to_s}.sort
      constants.map {|c| const_get(c)}
    end
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
state_manager-0.4.0 lib/state_manager/adapters.rb
state_manager-0.3.5 lib/state_manager/adapters.rb
state_manager-0.3.4 lib/state_manager/adapters.rb
state_manager-0.3.3 lib/state_manager/adapters.rb
state_manager-0.3.2 lib/state_manager/adapters.rb
state_manager-0.3.1 lib/state_manager/adapters.rb
state_manager-0.3.0 lib/state_manager/adapters.rb
state_manager-0.2.13 lib/state_manager/adapters.rb
state_manager-0.2.12 lib/state_manager/adapters.rb
state_manager-0.2.11 lib/state_manager/adapters.rb
state_manager-0.2.10 lib/state_manager/adapters.rb
state_manager-0.2.9 lib/state_manager/adapters.rb
state_manager-0.2.8 lib/state_manager/adapters.rb
state_manager-0.2.7 lib/state_manager/adapters.rb
state_manager-0.2.6 lib/state_manager/adapters.rb
state_manager-0.2.5 lib/state_manager/adapters.rb
state_manager-0.2.4 lib/state_manager/adapters.rb
state_manager-0.2.3 lib/state_manager/adapters.rb