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.
17 18 19 20 21 |
# File 'lib/dry/system/plugins.rb', line 17 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.
14 15 16 |
# File 'lib/dry/system/plugins.rb', line 14 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.
12 13 14 |
# File 'lib/dry/system/plugins.rb', line 12 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.
10 11 12 |
# File 'lib/dry/system/plugins.rb', line 10 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.
24 25 26 27 28 |
# File 'lib/dry/system/plugins.rb', line 24 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.
50 51 52 |
# File 'lib/dry/system/plugins.rb', line 50 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.
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/dry/system/plugins.rb', line 31 def load_dependencies Array(dependencies).each do |f| begin next if Plugins.loaded_dependencies.include?(f.to_s) require f Plugins.loaded_dependencies << f.to_s 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.
45 46 47 |
# File 'lib/dry/system/plugins.rb', line 45 def stateful? mod < Module end |