Class: Components::SourcesCard
- Inherits:
-
Base
- Object
- Base
- Components::SourcesCard
- Includes:
- Phlex::Rails::Helpers::LinkTo
- Defined in:
- app/components/sources_card.rb
Instance Method Summary collapse
- #before_template ⇒ Object
-
#initialize(model:) ⇒ SourcesCard
constructor
A new instance of SourcesCard.
- #render? ⇒ Boolean
- #view_template ⇒ Object
Constructor Details
#initialize(model:) ⇒ SourcesCard
Returns a new instance of SourcesCard.
8 9 10 |
# File 'app/components/sources_card.rb', line 8 def initialize(model:) @model = model end |
Instance Method Details
#before_template ⇒ Object
16 17 18 |
# File 'app/components/sources_card.rb', line 16 def before_template @sources = @model.relationships.where(predicate: "adapted_from").map { it.objekt } end |
#render? ⇒ Boolean
12 13 14 |
# File 'app/components/sources_card.rb', line 12 def render? @model.relationships.where(predicate: "adapted_from").any? end |
#view_template ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'app/components/sources_card.rb', line 20 def view_template Card title: t("components.sources_card.title"), variant: :secondary do div class: "card-text" do @sources.each do |source| ModelCard(model: source) end end end end |