Class: Harbor::Plugin
Direct Known Subclasses
String
Defined Under Namespace
Classes: String, VariableMissingError
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Hooks
included
#inject
Constructor Details
#initialize(context) ⇒ 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
|