Sha256: 6ba79679fbb116d86d4e2ba4569de6e734cacd63ff775cb985e3e2528b4c8767

Contents?: true

Size: 725 Bytes

Versions: 17

Compression:

Stored size: 725 Bytes

Contents

# frozen_string_literal: true

module Tramway
  module Collections
    module Helper
      def collection_list_by(name:)
        begin
          require name # needed to load class name with collection
        rescue LoadError
          raise "No such file #{name}. You should create file in the `lib/#{name}.rb` or elsewhere you want"
        end
        unless ::Tramway::Collection.descendants.map(&:to_s).include?(name.camelize)
          raise "There no such collection named #{name.camelize}. Please create class with self method `list` and extended of `Tramway::Collection`. You should reload your server after creating this collection."
        end

        name.camelize.constantize.list
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
tramway-core-1.17.2.1 lib/tramway/collections/helper.rb
tramway-core-1.17.2 lib/tramway/collections/helper.rb
tramway-core-1.17.1.1 lib/tramway/collections/helper.rb
tramway-core-1.17.1 lib/tramway/collections/helper.rb
tramway-core-1.17 lib/tramway/collections/helper.rb
tramway-core-1.16.2.1 lib/tramway/collections/helper.rb
tramway-core-1.16.2 lib/tramway/collections/helper.rb
tramway-core-1.16.1.9 lib/tramway/collections/helper.rb
tramway-core-1.16.1.8 lib/tramway/collections/helper.rb
tramway-core-1.16.1.7 lib/tramway/collections/helper.rb
tramway-core-1.16.1.6 lib/tramway/collections/helper.rb
tramway-core-1.16.1.5 lib/tramway/collections/helper.rb
tramway-core-1.16.1.4 lib/tramway/collections/helper.rb
tramway-core-1.16.1.3 lib/tramway/collections/helper.rb
tramway-core-1.16.1.2 lib/tramway/collections/helper.rb
tramway-core-1.16.1.1 lib/tramway/collections/helper.rb
tramway-core-1.16.1 lib/tramway/collections/helper.rb