lib/action_view/component/base.rb in actionview-component-1.5.3 vs lib/action_view/component/base.rb in actionview-component-1.6.0
- old
+ new
@@ -12,12 +12,10 @@
include ActiveSupport::Configurable
include ActionView::Component::Previews
delegate :form_authenticity_token, :protect_against_forgery?, to: :helpers
- validate :variant_exists
-
# Entrypoint for rendering components. Called by ActionView::Base#render.
#
# view_context: ActionView context from calling view
# args(hash): params to be passed to component being rendered
# block: optional block to be captured within the view context
@@ -92,16 +90,10 @@
@variant
end
private
- def variant_exists
- return if self.class.variants.include?(@variant) || @variant.nil?
-
- errors.add(:variant, "'#{@variant}' has no template defined")
- end
-
def request
@request ||= controller.request
end
attr_reader :content, :view_context
@@ -112,11 +104,11 @@
super
end
def call_method_name(variant)
- if variant.present?
+ if variant.present? && variants.include?(variant)
"call_#{variant}"
else
"call"
end
end
@@ -162,10 +154,10 @@
def type
"text/html"
end
def identifier
- ""
+ source_location
end
private
def templates