Class: EasyAdmin::Dashboards::CardFactory

Inherits:
Object
  • Object
show all
Defined in:
app/components/easy_admin/dashboards/card_factory.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.custom_componentsObject (readonly)

Returns the value of attribute custom_components.



8
9
10
# File 'app/components/easy_admin/dashboards/card_factory.rb', line 8

def custom_components
  @custom_components
end

Class Method Details

.create_component(card:, card_data:, dashboard_class:) ⇒ Object



10
11
12
13
14
15
16
17
# File 'app/components/easy_admin/dashboards/card_factory.rb', line 10

def create_component(card:, card_data:, dashboard_class:)
  component_class = resolve_component_class(card[:type], card)
  component_class.new(
    card: card,
    card_data: card_data,
    dashboard_class: dashboard_class
  )
end

.register(card_type, component_class) ⇒ Object

Register a custom card component CardFactory.register(:custom_analytics, MyApp::CustomAnalyticsCardComponent)



21
22
23
# File 'app/components/easy_admin/dashboards/card_factory.rb', line 21

def register(card_type, component_class)
  @custom_components[card_type.to_sym] = component_class
end

.unregister(card_type) ⇒ Object

Unregister a custom card component



26
27
28
# File 'app/components/easy_admin/dashboards/card_factory.rb', line 26

def unregister(card_type)
  @custom_components.delete(card_type.to_sym)
end