Class: ROM::Components::Core
- Inherits:
-
Object
- Object
- ROM::Components::Core
show all
- Extended by:
- Dry::Core::ClassAttributes, Initializer
- Includes:
- Dry::Core::Memoizable
- Defined in:
- lib/rom/components/core.rb,
lib/rom/compat/components.rb
Overview
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#config ⇒ Object
Returns Component's config.
#gateway ⇒ Object
42
|
# File 'lib/rom/components/core.rb', line 42
option :block, type: Types.Interface(:to_proc), optional: true
|
#provider ⇒ Object
Returns Component's provider.
34
|
# File 'lib/rom/components/core.rb', line 34
option :provider
|
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.
27
28
29
30
|
# File 'lib/rom/components/core.rb', line 27
def self.inherited(klass)
super
klass.type(Inflector.component_id(klass).to_sym)
end
|
Instance Method Details
#abstract ⇒ Object
Also known as:
abstract?
50
51
52
|
# File 'lib/rom/components/core.rb', line 50
def abstract
config.abstract
end
|
#apply_external_plugins(plugins, already_applied) ⇒ 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.
109
110
111
112
113
114
115
|
# File 'lib/rom/components/core.rb', line 109
def apply_external_plugins(plugins, already_applied)
plugins
.reject { |plugin| already_applied.include?(plugin.name) }
.each { |external_plugin|
config.plugins << external_plugin.configure.enable(constant).apply
}
end
|
#apply_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.
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/rom/components/core.rb', line 97
def apply_plugins
already_applied = plugins.reject(&:applied?).map do |plugin|
plugin.enable(constant) unless plugin.enabled?
plugin.apply unless plugin.applied?
plugin.name
end
apply_external_plugins(gateway_plugins, already_applied) if gateway?
apply_external_plugins(provider_plugins, already_applied)
end
|
#build ⇒ Object
This method is meant to return a run-time component instance
77
78
79
|
# File 'lib/rom/components/core.rb', line 77
def build(**)
raise NotImplementedError
end
|
#components ⇒ 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.
87
88
89
|
# File 'lib/rom/components/core.rb', line 87
def components
provider.components
end
|
#gateway? ⇒ Boolean
138
139
140
|
# File 'lib/rom/components/core.rb', line 138
def gateway?
registry.gateways.key?(config[:gateway])
end
|
#gateway_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.
123
124
125
|
# File 'lib/rom/components/core.rb', line 123
def gateway_plugins
gateway.config.plugins.select { |plugin| plugin.type == type }
end
|
#id ⇒ Object
65
66
67
|
# File 'lib/rom/components/core.rb', line 65
def id
config.id
end
|
#inflector ⇒ Object
82
83
84
|
# File 'lib/rom/components/core.rb', line 82
def inflector
config.inflector
end
|
#key ⇒ String
60
61
62
|
# File 'lib/rom/components/core.rb', line 60
memoize def key
"#{namespace}.#{id}"
end
|
#local_components ⇒ 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.
92
93
94
|
# File 'lib/rom/components/core.rb', line 92
def local_components
EMPTY_ARRAY
end
|
#namespace ⇒ Object
70
71
72
|
# File 'lib/rom/components/core.rb', line 70
def namespace
config.namespace
end
|
#notifications ⇒ 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.
16
17
18
|
# File 'lib/rom/compat/components.rb', line 16
def notifications
registry.notifications
end
|
#plugin_options ⇒ Object
133
134
135
|
# File 'lib/rom/components/core.rb', line 133
def plugin_options
plugins.map(&:plugin_options).reduce(:merge) || EMPTY_HASH
end
|
#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.
118
119
120
|
# File 'lib/rom/components/core.rb', line 118
def plugins
config.plugins.select { |plugin| plugin.type == type }
end
|
#provider_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.
128
129
130
|
# File 'lib/rom/components/core.rb', line 128
def provider_plugins
provider.config.component.plugins.select { |plugin| plugin.type == type }
end
|
#trigger(event, payload) ⇒ 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.
11
12
13
|
# File 'lib/rom/compat/components.rb', line 11
def trigger(event, payload)
registry.trigger("configuration.#{event}", payload)
end
|
#type ⇒ Object
45
46
47
|
# File 'lib/rom/components/core.rb', line 45
def type
self.class.type
end
|