Class: Rbexy::ComponentTagBuilder

Inherits:
ActionView::Helpers::TagHelper::TagBuilder
  • Object
show all
Defined in:
lib/rbexy/component_tag_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, component_provider) ⇒ ComponentTagBuilder

Returns a new instance of ComponentTagBuilder.



5
6
7
8
# File 'lib/rbexy/component_tag_builder.rb', line 5

def initialize(context, component_provider)
  super(context)
  @component_provider = component_provider
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(called, *args, **attrs, &block) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/rbexy/component_tag_builder.rb', line 10

def method_missing(called, *args, **attrs, &block)
  component_name = called.to_s.gsub("__", "::")
  if component_provider.match?(component_name)
    component_provider.render(@view_context, component_name, **attrs, &block)
  else
    super
  end
end

Instance Attribute Details

#component_providerObject (readonly)

Returns the value of attribute component_provider.



3
4
5
# File 'lib/rbexy/component_tag_builder.rb', line 3

def component_provider
  @component_provider
end