Class: Integral::ListItem

Inherits:
ApplicationRecord show all
Defined in:
app/models/integral/list_item.rb

Overview

Represents an item within a particular list

Direct Known Subclasses

Basic, Link, Object

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.types_collectionArray

Returns list of types available for a list item.

Returns:

  • (Array)

    list of types available for a list item



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/models/integral/list_item.rb', line 31

def self.types_collection
  collection = [
    [I18n.t('integral.backend.lists.items.type.basic'), 'Integral::Basic', data: { true_value: 'Integral::Basic' }],
    [I18n.t('integral.backend.lists.items.type.link'), 'Integral::Link', data: { true_value: 'Integral::Link' }]
  ]

  ActsAsListable.objects.each do |listable|
    object_data = {
      icon: listable.listable_options[:icon],
      object_type: listable.to_s,
      record_selector: listable.to_s.parameterize,
      true_value: 'Integral::Object'
    }

    collection << [listable.listable_options[:record_title], listable.to_s, data: object_data]
  end

  collection
end

Instance Method Details

#basic?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'app/models/integral/list_item.rb', line 59

def basic?
  false
end

#has_children?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'app/models/integral/list_item.rb', line 63

def has_children?
  children.present?
end

#link?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'app/models/integral/list_item.rb', line 55

def link?
  false
end

#object?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'app/models/integral/list_item.rb', line 51

def object?
  false
end