Class: Material::List

Inherits:
Collectible::CollectionBase
  • Object
show all
Includes:
Components, For, Icon, Mount, Pagination, Site, Text
Defined in:
lib/material/list.rb

Constant Summary

Constants included from Text

Text::DEFAULT_TRUNCATE_LENGTH

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mount

#mount_facet

Methods included from Pagination

#initialize

Class Method Details

.ensure_item_validity_with ⇒ Object



34
35
36
# File 'lib/material/list.rb', line 34

def ensure_item_validity_with
  super || item_class
end

.for(object) ⇒ Object



18
19
20
21
# File 'lib/material/list.rb', line 18

def for(object)
  material_class = material_class_for(object, "List")
  material_class.new if material_class.present?
end

.item_class ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/material/list.rb', line 23

def item_class
  return item_enforcement if item_enforcement.is_a?(Class)

  item_class = superclass.__send__(:item_enforcement) if superclass.respond_to?(:item_enforcement, true)
  return item_class if item_class.present?

  # Prevents against the case of `Material::List` becoming `Material` and returning a module
  item_class = name.chomp("List").safe_constantize
  item_class if item_class.is_a?(Class)
end

Instance Method Details

#default_title ⇒ Object



39
40
41
# File 'lib/material/list.rb', line 39

def default_title
  (item_class.try(:model_name)&.human || item_class&.name).pluralize || self.class.name
end