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

Methods inherited from ApplicationRecord

available_statuses

Class Method Details

.types_collectionArray

Returns list of types available for a list item.

Returns:

  • (Array)

    list of types available for a list item



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

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)


57
58
59
# File 'app/models/integral/list_item.rb', line 57

def basic?
  false
end

#has_children?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'app/models/integral/list_item.rb', line 61

def has_children?
  children.present?
end

#link?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'app/models/integral/list_item.rb', line 53

def link?
  false
end

#object?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'app/models/integral/list_item.rb', line 49

def object?
  false
end