Class: JetUi::Builder

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/jet_ui_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(view_context) ⇒ Builder

Returns a new instance of Builder.



11
12
13
# File 'app/helpers/jet_ui_helper.rb', line 11

def initialize(view_context)
  @view = view_context
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, **kwargs, &block) ⇒ Object



15
16
17
18
19
20
# File 'app/helpers/jet_ui_helper.rb', line 15

def method_missing(name, *args, **kwargs, &block)
  component_class = resolve_component(name)
  content = args.shift if args.first.is_a?(String)
  instance = component_class.new(*args, **kwargs)
  content ? @view.render(instance) { content } : @view.render(instance, &block)
end

Instance Method Details

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
# File 'app/helpers/jet_ui_helper.rb', line 22

def respond_to_missing?(name, include_private = false)
  resolve_component(name)
  true
rescue NameError
  super
end