Class: Dry::System::Plugins::Plugin Private
- Inherits:
-
Object
- Object
- Dry::System::Plugins::Plugin
- Defined in:
- lib/dry/system/plugins.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #block ⇒ Object readonly private
- #mod ⇒ Object readonly private
- #name ⇒ Object readonly private
Instance Method Summary collapse
- #apply_to(system, options) ⇒ Object private
- #dependencies ⇒ Object private
-
#initialize(name, mod, &block) ⇒ Plugin
constructor
private
A new instance of Plugin.
- #load_dependencies ⇒ Object private
- #stateful? ⇒ Boolean private
Constructor Details
#initialize(name, mod, &block) ⇒ Plugin
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.
Returns a new instance of Plugin.
15 16 17 18 19 |
# File 'lib/dry/system/plugins.rb', line 15 def initialize(name, mod, &block) @name = name @mod = mod @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
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.
12 13 14 |
# File 'lib/dry/system/plugins.rb', line 12 def block @block end |
#mod ⇒ Object (readonly)
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.
10 11 12 |
# File 'lib/dry/system/plugins.rb', line 10 def mod @mod end |
#name ⇒ Object (readonly)
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.
8 9 10 |
# File 'lib/dry/system/plugins.rb', line 8 def name @name end |
Instance Method Details
#apply_to(system, 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.
22 23 24 25 26 |
# File 'lib/dry/system/plugins.rb', line 22 def apply_to(system, ) system.extend(stateful? ? mod.new() : mod) system.instance_eval(&block) if block system end |
#dependencies ⇒ 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.
46 47 48 |
# File 'lib/dry/system/plugins.rb', line 46 def dependencies mod.respond_to?(:dependencies) ? Array(mod.dependencies) : EMPTY_ARRAY end |
#load_dependencies ⇒ 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.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/dry/system/plugins.rb', line 29 def load_dependencies Array(dependencies).each do |f| begin require f unless Plugins.loaded_dependencies.include?(f) Plugins.loaded_dependencies << f rescue LoadError => e raise PluginDependencyMissing.new(name, e.) end end end |
#stateful? ⇒ Boolean
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 |
# File 'lib/dry/system/plugins.rb', line 41 def stateful? mod < Module end |