class Material::List
Public Class Methods
for(object)
click to toggle source
# File lib/material/list.rb, line 19 def for(object) klass = for_class((object.respond_to?(:to_ary) && object.respond_to?(:first)) ? object.first : object) materialize(object, klass) if klass.present? end
for_class(object)
click to toggle source
# File lib/material/list.rb, line 24 def for_class(object) object.try(:conjugate!, self) end
Private Class Methods
materialize(object, klass)
click to toggle source
# File lib/material/list.rb, line 32 def materialize(object, klass) return klass.new(object) if object.present? && !object.is_a?(Class) klass.new end
Public Instance Methods
contextualize(parent)
click to toggle source
# File lib/material/list.rb, line 42 def contextualize(parent) @context_parent = parent end
default_parent()
click to toggle source
# File lib/material/list.rb, line 46 def default_parent @context_parent end
default_title()
click to toggle source
# File lib/material/list.rb, line 50 def default_title (item_class.try(:model_name)&.human || item_class&.name).pluralize || self.class.name end