Class: Jav::CardComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/jav/card_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(card: nil) ⇒ CardComponent

Returns a new instance of CardComponent.



6
7
8
9
10
11
# File 'app/components/jav/card_component.rb', line 6

def initialize(card: nil)
  super
  @card = card

  init_card
end

Instance Attribute Details

#cardObject (readonly)

Returns the value of attribute card.



4
5
6
# File 'app/components/jav/card_component.rb', line 4

def card
  @card
end

Instance Method Details

#init_cardObject

Initializing the card byt running the query method. We'll still keep the query block around for compatibility reasons.



19
20
21
22
23
24
25
# File 'app/components/jav/card_component.rb', line 19

def init_card
  if card.respond_to? :query
    card.query
  elsif card.query_block.present?
    card.compute_result
  end
end

#render?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'app/components/jav/card_component.rb', line 13

def render?
  card.present?
end