Class: Avo::CardComponent

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

Instance Method Summary collapse

Constructor Details

#initialize(card: nil) ⇒ CardComponent

Returns a new instance of CardComponent.



4
5
6
7
8
# File 'app/components/avo/card_component.rb', line 4

def initialize(card: nil)
  @card = card

  init_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.



16
17
18
19
20
21
22
# File 'app/components/avo/card_component.rb', line 16

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

#render?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'app/components/avo/card_component.rb', line 10

def render?
  !@card.nil?
end