Class: Tramway::EntityComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/tramway/entity_component.rb

Overview

Component for displaying an entity row in a list

Instance Method Summary collapse

Instance Method Details

#cellsObject



22
23
24
25
26
# File 'app/components/tramway/entity_component.rb', line 22

def cells
  decorated_item.class.index_attributes.reduce({}) do |hash, attribute|
    hash.merge! attribute => decorated_item.public_send(attribute)
  end
end

#decorated_itemObject



10
11
12
# File 'app/components/tramway/entity_component.rb', line 10

def decorated_item
  tramway_decorate item, namespace: entity.namespace
end

#hrefObject



14
15
16
17
18
19
20
# File 'app/components/tramway/entity_component.rb', line 14

def href
  if entity.pages.find { _1.action == 'show' }.present?
    Tramway::Engine.routes.url_helpers.public_send entity.routes.show, decorated_item.id
  else
    decorated_item.show_path
  end
end