Class: MetadataPresenter::Component

Inherits:
Metadata
  • Object
show all
Defined in:
app/models/metadata_presenter/component.rb

Constant Summary collapse

SUPPORTS_BRANCHING =
%w[radios checkboxes].freeze

Instance Attribute Summary

Attributes inherited from Metadata

#metadata

Instance Method Summary collapse

Methods inherited from Metadata

#==, #editor?, #id, #initialize, #method_missing, #respond_to_missing?, #to_json, #type, #uuid

Constructor Details

This class inherits a constructor from MetadataPresenter::Metadata

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class MetadataPresenter::Metadata

Instance Method Details

#content?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'app/models/metadata_presenter/component.rb', line 22

def content?
  type == 'content'
end

#find_item_by_uuid(uuid) ⇒ Object



30
31
32
# File 'app/models/metadata_presenter/component.rb', line 30

def find_item_by_uuid(uuid)
  items.find { |item| item.uuid == uuid }
end

#humanised_titleObject



6
7
8
# File 'app/models/metadata_presenter/component.rb', line 6

def humanised_title
  label || legend
end

#itemsObject



10
11
12
13
14
# File 'app/models/metadata_presenter/component.rb', line 10

def items
  Array(.items).map do |item|
    MetadataPresenter::Item.new(item, editor: editor?)
  end
end

#supports_branching?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'app/models/metadata_presenter/component.rb', line 18

def supports_branching?
  type.in?(SUPPORTS_BRANCHING)
end

#to_partial_pathObject



2
3
4
# File 'app/models/metadata_presenter/component.rb', line 2

def to_partial_path
  "metadata_presenter/component/#{type}"
end

#upload?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'app/models/metadata_presenter/component.rb', line 26

def upload?
  type == 'upload'
end