Module: ViewComponent::Form::Renderer
- Included in:
- Builder
- Defined in:
- lib/view_component/form/renderer.rb
Defined Under Namespace
Classes: Error, NamespaceAlreadyAddedError, NotImplementedComponentError
Class Method Summary collapse
-
.included(base) ⇒ Object
rubocop:disable Metrics/MethodLength.
Class Method Details
.included(base) ⇒ Object
rubocop:disable Metrics/MethodLength
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/view_component/form/renderer.rb', line 11 def self.included(base) base.class_eval do original_initialize_method = instance_method(:initialize) define_method(:initialize) do |*args, &block| @__component_klass_cache = {} original_initialize_method.bind_call(self, *args, &block) end class_attribute :lookup_namespaces, default: [ViewComponent::Form] class << self def inherited(base) base.lookup_namespaces = lookup_namespaces.dup super end def namespace(namespace) if lookup_namespaces.include?(namespace) raise NamespaceAlreadyAddedError, "The component namespace '#{namespace}' is already added" end lookup_namespaces.prepend namespace end end end end |