Class: NfgUi::UI::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/nfg_ui/ui/base.rb

Overview

The base component building class for namespaced components (bootstrap vs network_for_good / nfg)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view_context) ⇒ Base

Returns a new instance of Base.



10
11
12
# File 'lib/nfg_ui/ui/base.rb', line 10

def initialize(view_context)
  self.view_context = view_context
end

Instance Attribute Details

#view_contextObject

Returns the value of attribute view_context.



8
9
10
# File 'lib/nfg_ui/ui/base.rb', line 8

def view_context
  @view_context
end

Instance Method Details

#bootstrap(component_name = nil, *traits, **options, &block) ⇒ Object



14
15
16
# File 'lib/nfg_ui/ui/base.rb', line 14

def bootstrap(component_name = nil, *traits, **options, &block)
  NfgUi::UI::Bootstrap.new(view_context, component_name, *traits, **options, &block).render_component
end

#nfg(component_name = nil, *traits, **options, &block) ⇒ Object



18
19
20
21
# File 'lib/nfg_ui/ui/base.rb', line 18

def nfg(component_name = nil, *traits, **options, &block)
  return unless render_nfg_component?(options)
  NfgUi::UI::NetworkForGood.new(view_context, component_name, *traits, **options, &block).render_component
end