Class: Deptree::Dependency

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#actionsObject (readonly)

Returns the value of attribute actions.



3
4
5
# File 'lib/deptree/dependency.rb', line 3

def actions
  @actions
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/deptree/dependency.rb', line 3

def name
  @name
end

#prerequisitesObject (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_contextObject



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