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.
104
105
106
107
108
109
110
111
112
|
# File 'lib/view_component/template.rb', line 104
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
118
119
120
|
# File 'lib/view_component/template.rb', line 118
def compile_to_component
@component.define_method(safe_method_name, @component.instance_method(@call_method_name))
end
|
#defined_on_self? ⇒ Boolean
132
133
134
|
# File 'lib/view_component/template.rb', line 132
def defined_on_self?
@defined_on_self
end
|
#safe_method_name_call ⇒ Object
122
123
124
125
126
127
128
129
130
|
# File 'lib/view_component/template.rb', line 122
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
114
115
116
|
# File 'lib/view_component/template.rb', line 114
def type
:inline_call
end
|