Class: Components::RemixesCard

Inherits:
Base
  • Object
show all
Includes:
Phlex::Rails::Helpers::LinkTo
Defined in:
app/components/remixes_card.rb

Instance Method Summary collapse

Constructor Details

#initialize(model:) ⇒ RemixesCard

Returns a new instance of RemixesCard.



8
9
10
# File 'app/components/remixes_card.rb', line 8

def initialize(model:)
  @model = model
end

Instance Method Details

#before_template ⇒ Object



16
17
18
# File 'app/components/remixes_card.rb', line 16

def before_template
  @remixes = @model.reverse_relationships.where(predicate: "adapted_from").map { it.subject }
end

#render? ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'app/components/remixes_card.rb', line 12

def render?
  @model.reverse_relationships.where(predicate: "adapted_from").any?
end

#view_template ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'app/components/remixes_card.rb', line 20

def view_template
  Card title: t("components.remixes_card.title"), variant: :secondary do
    div class: "card-text" do
      @remixes.each do |remix|
        ModelCard(model: remix)
      end
    end
  end
end