Class: Deptree::Dependency
- Inherits:
-
Object
- Object
- Deptree::Dependency
- Defined in:
- lib/deptree/dependency.rb,
lib/deptree/dependency/actions.rb,
lib/deptree/dependency/prerequsites_proxy.rb
Defined Under Namespace
Classes: Action, Actions, PrerequisitesProxy
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#prerequisites ⇒ Object
readonly
Returns the value of attribute prerequisites.
Instance Method Summary collapse
- #action(name, &behaviour) ⇒ Object
- #execute(name) ⇒ Object
- #execution_context ⇒ Object
-
#initialize(name, prerequisites, helpers) ⇒ Dependency
constructor
A new instance of Dependency.
Constructor Details
#initialize(name, prerequisites, helpers) ⇒ Dependency
Returns a new instance of Dependency.
5 6 7 8 9 10 |
# File 'lib/deptree/dependency.rb', line 5 def initialize(name, prerequisites, helpers) @name = name @prerequisites = prerequisites @helpers = helpers @actions = Actions.new(self) end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
3 4 5 |
# File 'lib/deptree/dependency.rb', line 3 def actions @actions end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/deptree/dependency.rb', line 3 def name @name end |
#prerequisites ⇒ Object (readonly)
Returns the value of attribute prerequisites.
3 4 5 |
# File 'lib/deptree/dependency.rb', line 3 def prerequisites @prerequisites end |
Instance Method Details
#action(name, &behaviour) ⇒ Object
12 13 14 |
# File 'lib/deptree/dependency.rb', line 12 def action(name, &behaviour) @actions.add(name, behaviour) end |
#execute(name) ⇒ Object
16 17 18 19 20 |
# File 'lib/deptree/dependency.rb', line 16 def execute(name) if (action = @actions.find(name)) action.execute end end |
#execution_context ⇒ Object
22 23 24 25 26 |
# File 'lib/deptree/dependency.rb', line 22 def execution_context @execution_context ||= Object.new.tap do |ctx| ctx.extend(@helpers) end end |