module Ditty::Components::Base::ClassMethods
Public Instance Methods
component(component, *args, &block)
click to toggle source
Load a new component into the current class. A component can be a module which is used directly, or a symbol represented a registered component which will be required and then used. Returns nil.
Component.component ComponentModule Component.component :csrf
# File lib/ditty.rb, line 147 def component(component, *args, &block) raise ComponentError, 'Cannot add a component to a frozen Component class' if frozen? component = Components.load_component(component) if component.is_a?(Symbol) include(component::InstanceMethods) if defined?(component::InstanceMethods) extend(component::ClassMethods) if defined?(component::ClassMethods) component.configure(self, *args, &block) if component.respond_to?(:configure) nil end