Class: ROM::Components::DSL::Core
- Inherits:
-
Object
- Object
- ROM::Components::DSL::Core
- Extended by:
- Dry::Core::ClassAttributes, Initializer
- Includes:
- Dry::Core::Memoizable, Plugins::ClassMethods
- Defined in:
- lib/rom/components/dsl/core.rb
Class Method Summary collapse
- .inherited(klass) ⇒ Object private
Instance Method Summary collapse
- #build_class(name: class_name, parent: class_parent, &block) ⇒ Object private
- #call(**options) ⇒ Object private
- #configure ⇒ Object private
- #enable_plugins ⇒ Object private
- #enabled_plugins ⇒ Object private
- #key ⇒ Object private
- #plugin(name, **options) ⇒ Object private
- #type ⇒ Object private
Methods included from Initializer
Methods included from Plugins::ClassMethods
Class Method Details
.inherited(klass) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
35 36 37 38 |
# File 'lib/rom/components/dsl/core.rb', line 35 def self.inherited(klass) super klass.type(Inflector.component_id(klass).to_sym) end |
Instance Method Details
#build_class(name: class_name, parent: class_parent, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
41 42 43 44 45 46 |
# File 'lib/rom/components/dsl/core.rb', line 41 def build_class(name: class_name, parent: class_parent, &block) Dry::Core::ClassBuilder.new(name: name, parent: parent).call do |klass| klass.config.component.update(config) klass.class_exec(self, &block) if block end end |
#call(**options) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
59 60 61 |
# File 'lib/rom/components/dsl/core.rb', line 59 def call(**) components.add(key, config: configure, block: block, **) end |
#configure ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
64 65 66 |
# File 'lib/rom/components/dsl/core.rb', line 64 def configure config.freeze end |
#enable_plugins ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/rom/components/dsl/core.rb', line 83 def enable_plugins config.plugins.map! do |plugin| if plugin.is_a?(Symbol) plugins[plugin].configure.enable(self) elsif plugin.type == type plugin.configure.enable(respond_to?(:constant) ? constant : self) else plugin end end end |
#enabled_plugins ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
76 77 78 79 80 |
# File 'lib/rom/components/dsl/core.rb', line 76 def enabled_plugins config.plugins .select { |plugin| plugin.type == type } .to_h { |plugin| [plugin.name, plugin] } end |
#key ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 |
# File 'lib/rom/components/dsl/core.rb', line 49 def key self.class.key end |
#plugin(name, **options) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
69 70 71 72 73 |
# File 'lib/rom/components/dsl/core.rb', line 69 def plugin(name, **) plugin = enabled_plugins[name] plugin.config.update() unless .empty? plugin end |
#type ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
54 55 56 |
# File 'lib/rom/components/dsl/core.rb', line 54 def type self.class.type end |