Sha256: db47fb272d5caa7c331356af89df11bc0ccde23f13faae6dcdf4bdbf38d4221f

Contents?: true

Size: 642 Bytes

Versions: 77

Compression:

Stored size: 642 Bytes

Contents

# frozen_string_literal: true

require 'tramway/collections'

module Tramway::Collections::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)
      ::Tramway::Error.raise_error(
        :tramway, :collections, :helper, :collection_list_by, :there_no_such_collection,
        name_camelize: name.camelize
      )
    end

    name.camelize.constantize.list
  end
end

Version data entries

77 entries across 77 versions & 2 rubygems

Version Path
tramway-core-1.18.5.2 lib/tramway/collections/helper.rb
tramway-core-1.18.5.1 lib/tramway/collections/helper.rb
tramway-core-1.18.5 lib/tramway/collections/helper.rb
tramway-core-1.18.4 lib/tramway/collections/helper.rb
tramway-core-1.18.3.5 lib/tramway/collections/helper.rb
tramway-core-1.18.3.4 lib/tramway/collections/helper.rb
tramway-core-1.18.3.3 lib/tramway/collections/helper.rb
tramway-core-1.18.3.2 lib/tramway/collections/helper.rb
tramway-core-1.18.3.1 lib/tramway/collections/helper.rb
tramway-core-1.18.3 lib/tramway/collections/helper.rb
tramway-core-1.18.2 lib/tramway/collections/helper.rb
tramway-core-1.18.1.2 lib/tramway/collections/helper.rb
tramway-core-1.18.1.1 lib/tramway/collections/helper.rb
tramway-core-1.18.1 lib/tramway/collections/helper.rb
tramway-core-1.18.0.4 lib/tramway/collections/helper.rb
tramway-core-1.18.0.3 lib/tramway/collections/helper.rb
tramway-core-1.18.0.2 lib/tramway/collections/helper.rb
tramway-core-1.18.0.1 lib/tramway/collections/helper.rb
tramway-core-1.18 lib/tramway/collections/helper.rb
tramway-core-1.17.9.1 lib/tramway/collections/helper.rb