Class: Material::List

Inherits:
Collectible::CollectionBase
  • Object
show all
Includes:
Conjunction::Junction, Collection, Components, Display, Format, Mount, Pagination, Site, Text
Defined in:
lib/material/list.rb

Constant Summary

Constants included from Text

Text::DEFAULT_TRUNCATE_LENGTH

Constants included from Components

Components::CLASSES_TO_DUPLICATE

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Collection

#to_ary

Methods included from Mount

#mount_facet

Methods included from Pagination

#initialize

Class Method Details

.for(object) ⇒ Object



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

def for(object)
  klass = for_class(object.respond_to?(:first) ? object.first : object)
  materialize(object, klass) if klass.present?
end

.for_class(object) ⇒ Object



23
24
25
# File 'lib/material/list.rb', line 23

def for_class(object)
  object.try(:conjugate!, self)
end

Instance Method Details

#contextualize(parent) ⇒ Object



36
37
38
# File 'lib/material/list.rb', line 36

def contextualize(parent)
  @context_parent = parent
end

#default_parentObject



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

def default_parent
  @context_parent
end

#default_titleObject



44
45
46
# File 'lib/material/list.rb', line 44

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