Class: ViewComponent::Template::InlineCall
Instance Attribute Summary
#details, #path
Instance Method Summary
collapse
#call_method_name, #coverage_running?, #default_format?, #inline_call?, #normalized_variant_name, #requires_compiled_superclass?, #safe_method_name
Constructor Details
#initialize(component:, method_name:, defined_on_self:) ⇒ InlineCall
Returns a new instance of InlineCall.
106
107
108
109
110
111
112
113
114
|
# File 'lib/view_component/template.rb', line 106
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
120
121
122
|
# File 'lib/view_component/template.rb', line 120
def compile_to_component
@component.define_method(safe_method_name, @component.instance_method(@call_method_name))
end
|
#defined_on_self? ⇒ Boolean
134
135
136
|
# File 'lib/view_component/template.rb', line 134
def defined_on_self?
@defined_on_self
end
|
#safe_method_name_call ⇒ Object
124
125
126
127
128
129
130
131
132
|
# File 'lib/view_component/template.rb', line 124
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
116
117
118
|
# File 'lib/view_component/template.rb', line 116
def type
:inline_call
end
|