Sha256: d7e8c17c212c548813ac40090f9e3c4a2753cdeb17f716d7b6d4c3f8a5b5001e

Contents?: true

Size: 523 Bytes

Versions: 8

Compression:

Stored size: 523 Bytes

Contents

# frozen_string_literal: true

module FreightKit
  module Carriers
    extend self

    attr_reader :registered

    @registered = []

    def register(class_name, autoload_require)
      FreightKit.autoload(class_name, autoload_require)
      registered << class_name
    end

    def all
      FreightKit::Carriers.registered.map { |name| FreightKit.const_get(name) }
    end

    def find(name)
      all.find { |c| c.name.downcase == name.to_s.downcase } or raise NameError, "unknown carrier #{name}"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
freight_kit-0.1.11 lib/freight_kit/carriers.rb
freight_kit-0.1.10 lib/freight_kit/carriers.rb
freight_kit-0.1.7 lib/freight_kit/carriers.rb
freight_kit-0.1.4 lib/freight_kit/carriers.rb
freight_kit-0.1.3 lib/freight_kit/carriers.rb
freight_kit-0.1.2 lib/freight_kit/carriers.rb
freight_kit-0.1.1 lib/freight_kit/carriers.rb
freight_kit-0.1.0 lib/freight_kit/carriers.rb