Class: Coral::Plugin::Base
- Defined in:
- lib/coral_core/plugin_base.rb
Instance Attribute Summary
Attributes inherited from Core
Class Method Summary collapse
-
.build_info(type, data) ⇒ Object
—————————————————————————– Utilities.
-
.ensure_plugin_collection ⇒ Object
—.
-
.translate(data) ⇒ Object
—.
Instance Method Summary collapse
-
#initialize(type, provider, options) ⇒ Base
constructor
All Plugin classes should directly or indirectly extend Base.
-
#initialized?(options = {}) ⇒ Boolean
—.
-
#meta ⇒ Object
—.
-
#method_missing(method, *args, &block) ⇒ Object
—.
-
#name ⇒ Object
—————————————————————————– Property accessor / modifiers.
-
#name=(name) ⇒ Object
—.
-
#normalize ⇒ Object
—————————————————————————– Plugin operations.
-
#plugin_directory ⇒ Object
—.
-
#plugin_file ⇒ Object
—.
-
#plugin_instance_name ⇒ Object
—.
-
#plugin_parent ⇒ Object
—.
-
#plugin_parent=(parent) ⇒ Object
—.
-
#plugin_provider ⇒ Object
—.
-
#plugin_type ⇒ Object
—.
-
#set_meta(meta) ⇒ Object
—.
Methods inherited from Core
#inspect, logger, #logger, logger=, ui
Methods inherited from Config
#[], #[]=, array, #array, #clear, #defaults, #delete, ensure, #export, filter, #filter, #get, #get_array, #get_hash, #hash, hash, #import, #init, init, init_flat, #set, string, #string, #string_map, string_map, symbol, #symbol, #symbol_map, symbol_map, test, #test
Methods included from Mixin::ConfigOptions
#clear_options, #contexts, #get_options, #set_options
Methods included from Mixin::ConfigCollection
#all_properties, #clear_properties, #delete_property, #get_property, #save_properties, #set_property
Methods included from Mixin::Lookup
#hiera, #hiera_config, #lookup, #lookup_array, #lookup_hash
Methods included from Mixin::ConfigOps
Constructor Details
#initialize(type, provider, options) ⇒ Base
All Plugin classes should directly or indirectly extend Base
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/coral_core/plugin_base.rb', line 7 def initialize(type, provider, ) config = Config.ensure() name = Util::Data.ensure_value(config.delete(:name), provider) (config.delete(:meta, Config.new)) super(config) self.name = name normalize end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
28 29 30 |
# File 'lib/coral_core/plugin_base.rb', line 28 def method_missing(method, *args, &block) return nil end |
Class Method Details
.build_info(type, data) ⇒ Object
Utilities
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/coral_core/plugin_base.rb', line 108 def self.build_info(type, data) plugins = [] if data.is_a?(Hash) data = [ data ] end if data.is_a?(Array) data.each do |info| unless Util::Data.empty?(info) info = translate(info) if Util::Data.empty?(info[:provider]) info[:provider] = Plugin.type_default(type) end plugins << info end end end return plugins end |
.ensure_plugin_collection ⇒ Object
139 140 141 142 143 144 |
# File 'lib/coral_core/plugin_base.rb', line 139 def self.ensure_plugin_collection include Mixin::Settings include Mixin::SubConfig extend Mixin::Macro::PluginInterface end |
.translate(data) ⇒ Object
133 134 135 |
# File 'lib/coral_core/plugin_base.rb', line 133 def self.translate(data) return ( data.is_a?(Hash) ? symbol_map(data) : {} ) end |
Instance Method Details
#initialized?(options = {}) ⇒ Boolean
22 23 24 |
# File 'lib/coral_core/plugin_base.rb', line 22 def initialized?( = {}) return true end |
#meta ⇒ Object
47 48 49 |
# File 'lib/coral_core/plugin_base.rb', line 47 def return @meta end |
#name ⇒ Object
Property accessor / modifiers
35 36 37 |
# File 'lib/coral_core/plugin_base.rb', line 35 def name return get(:name) end |
#name=(name) ⇒ Object
41 42 43 |
# File 'lib/coral_core/plugin_base.rb', line 41 def name=name set(:name, string(name)) end |
#normalize ⇒ Object
Plugin operations
102 103 |
# File 'lib/coral_core/plugin_base.rb', line 102 def normalize end |
#plugin_directory ⇒ Object
71 72 73 |
# File 'lib/coral_core/plugin_base.rb', line 71 def plugin_directory return .get(:directory) end |
#plugin_file ⇒ Object
77 78 79 |
# File 'lib/coral_core/plugin_base.rb', line 77 def plugin_file return .get(:file) end |
#plugin_instance_name ⇒ Object
83 84 85 |
# File 'lib/coral_core/plugin_base.rb', line 83 def plugin_instance_name return .get(:instance_name) end |
#plugin_parent ⇒ Object
95 96 97 |
# File 'lib/coral_core/plugin_base.rb', line 95 def plugin_parent return .get(:parent) end |
#plugin_parent=(parent) ⇒ Object
89 90 91 |
# File 'lib/coral_core/plugin_base.rb', line 89 def plugin_parent=parent .set(:parent, parent) if parent.is_a?(Coral::Plugin::Base) end |
#plugin_provider ⇒ Object
65 66 67 |
# File 'lib/coral_core/plugin_base.rb', line 65 def plugin_provider return .get(:provider) end |
#plugin_type ⇒ Object
59 60 61 |
# File 'lib/coral_core/plugin_base.rb', line 59 def plugin_type return .get(:type) end |