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.
113
114
115
116
117
118
119
120
121
|
# File 'lib/view_component/template.rb', line 113
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
127
128
129
|
# File 'lib/view_component/template.rb', line 127
def compile_to_component
@component.define_method(safe_method_name, @component.instance_method(@call_method_name))
end
|
#defined_on_self? ⇒ Boolean
141
142
143
|
# File 'lib/view_component/template.rb', line 141
def defined_on_self?
@defined_on_self
end
|
#safe_method_name_call ⇒ Object
131
132
133
134
135
136
137
138
139
|
# File 'lib/view_component/template.rb', line 131
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
123
124
125
|
# File 'lib/view_component/template.rb', line 123
def type
:inline_call
end
|