Class: Confiner::Plugin
- Inherits:
-
Object
- Object
- Confiner::Plugin
- Includes:
- Logger
- Defined in:
- lib/confiner/plugin.rb
Overview
Plugin for Confiner
Direct Known Subclasses
Instance Attribute Summary collapse
-
#examples ⇒ Object
readonly
Returns the value of attribute examples.
Class Method Summary collapse
-
.arguments(*args) ⇒ Object
Define arguments that the plugin will accept.
Instance Method Summary collapse
-
#initialize(**args) ⇒ Plugin
constructor
A new instance of Plugin.
-
#run(action) {|_self| ... } ⇒ Object
Run the plugin.
Methods included from Logger
Constructor Details
#initialize(**args) ⇒ Plugin
Returns a new instance of Plugin.
35 36 37 38 39 |
# File 'lib/confiner/plugin.rb', line 35 def initialize(**args) args.each do |k, v| self.public_send(:"#{k}=", v) end end |
Instance Attribute Details
#examples ⇒ Object (readonly)
Returns the value of attribute examples.
8 9 10 |
# File 'lib/confiner/plugin.rb', line 8 def examples @examples end |
Class Method Details
.arguments(*args) ⇒ Object
Note:
the arguments should be well-formed in the .yml rule file
Define arguments that the plugin will accept
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/confiner/plugin.rb', line 16 def arguments(*args) @arguments ||= args args.each do |arg| if arg.is_a? Hash arg.each do |a, default_value| attr_writer a define_method(a) do instance_variable_get("@#{a}") || instance_variable_set("@#{a}", default_value) end end else attr_accessor arg end end end |
Instance Method Details
#run(action) {|_self| ... } ⇒ Object
Run the plugin
42 43 44 |
# File 'lib/confiner/plugin.rb', line 42 def run(action, &block) yield self end |