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
48
# 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 = {
      object_type: listable.to_s,
      true_value: 'Integral::Object',
      resource_selector_title: 'Select resource..',
      resource_selector_url: listable.integral_resource_selector_url,
      icon: listable.integral_icon
    }

    collection << [listable.model_name.human, listable.to_s, data: object_data]
  end

  collection
end

Instance Method Details

#basic?Boolean

Returns:

  • (Boolean)


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

def basic?
  false
end

#has_children?Boolean

Returns:

  • (Boolean)


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

def has_children?
  children.present?
end

#link?Boolean

Returns:

  • (Boolean)


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

def link?
  false
end

#object?Boolean

Returns:

  • (Boolean)


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

def object?
  false
end