Class: ViewComponent::Template::InlineCall
- Inherits:
-
Template
- Object
- Template
- ViewComponent::Template::InlineCall
- Defined in:
- lib/view_component/template.rb
Instance Method Summary collapse
- #compile_to_component ⇒ Object
- #defined_on_self? ⇒ Boolean
-
#initialize(component:, method_name:, defined_on_self:) ⇒ InlineCall
constructor
A new instance of InlineCall.
- #safe_method_name_call ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(component:, method_name:, defined_on_self:) ⇒ InlineCall
Returns a new instance of InlineCall.
112 113 114 115 116 117 118 119 120 |
# File 'lib/view_component/template.rb', line 112 def initialize(component:, method_name:, defined_on_self:) variant = method_name.to_s.include?("call_") ? method_name.to_s.sub("call_", "").to_sym : nil details = ActionView::TemplateDetails.new(nil, nil, nil, variant) super(component: component, details: details) @call_method_name = method_name @defined_on_self = defined_on_self end |
Instance Method Details
#compile_to_component ⇒ Object
126 127 128 |
# File 'lib/view_component/template.rb', line 126 def compile_to_component @component.define_method(safe_method_name, @component.instance_method(@call_method_name)) end |
#defined_on_self? ⇒ Boolean
140 141 142 |
# File 'lib/view_component/template.rb', line 140 def defined_on_self? @defined_on_self end |
#safe_method_name_call ⇒ Object
130 131 132 133 134 135 136 137 138 |
# File 'lib/view_component/template.rb', line 130 def safe_method_name_call m = safe_method_name proc do __vc_maybe_escape_html(send(m)) do Kernel.warn("WARNING: The #{self.class} component rendered HTML-unsafe output. " \ "The output will be automatically escaped, but you may want to investigate.") end end end |
#type ⇒ Object
122 123 124 |
# File 'lib/view_component/template.rb', line 122 def type :inline_call end |