Class: Harbor::Plugin
- Inherits:
-
Object
- Object
- Harbor::Plugin
- Includes:
- AccessorInjector, Hooks
- Defined in:
- lib/harbor/plugin.rb
Direct Known Subclasses
Defined Under Namespace
Classes: String, VariableMissingError
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(context) ⇒ Plugin
constructor
A new instance of Plugin.
- #to_s ⇒ Object
Methods included from Hooks
Methods included from AccessorInjector
Constructor Details
#initialize(context) ⇒ Plugin
Returns a new instance of Plugin.
25 26 27 |
# File 'lib/harbor/plugin.rb', line 25 def initialize(context) @context = context end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
15 16 17 |
# File 'lib/harbor/plugin.rb', line 15 def context @context end |
Class Method Details
.prepare(plugin, context, variables) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/harbor/plugin.rb', line 17 def self.prepare(plugin, context, variables) if plugin.is_a?(Class) plugin.new(context).inject(variables) else plugin.inject({ :context => context }.merge(variables)) end end |
.requires(key) ⇒ Object
29 30 31 32 33 |
# File 'lib/harbor/plugin.rb', line 29 def self.requires(key) before(:to_s) do |instance| raise VariableMissingError.new(self, key) unless instance.instance_variable_defined?("@#{key}") end end |
Instance Method Details
#to_s ⇒ Object
35 36 37 |
# File 'lib/harbor/plugin.rb', line 35 def to_s raise NotImplementedError.new("You must define your own #to_s method.") end |