Module: Tramway::Collections::Helper

Defined in:
lib/tramway/collections/helper.rb

Instance Method Summary collapse

Instance Method Details

#collection_list_by(name:) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/tramway/collections/helper.rb', line 4

def collection_list_by(name:)
  require name # needed to load class name with collection
  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`" 
  end

  name.camelize.constantize.list
end