Class: Deptree::Dependency::Actions

Inherits:
Object
  • Object
show all
Defined in:
lib/deptree/dependency/actions.rb

Instance Method Summary collapse

Constructor Details

#initialize(dependency) ⇒ Actions

Returns a new instance of Actions.



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

def initialize(dependency)
  @dependency, @actions = dependency, []
end

Instance Method Details

#add(name, behaviour) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/deptree/dependency/actions.rb', line 8

def add(name, behaviour)
  fail DuplicateActionError.new(@dependency.name, name) if find(name)

  action = Action.new(name, behaviour, @dependency.execution_context)
  @actions << action
  action
end

#find(name) ⇒ Object



16
17
18
# File 'lib/deptree/dependency/actions.rb', line 16

def find(name)
  @actions.find { |a| a.name == name }
end

#sizeObject



20
21
22
# File 'lib/deptree/dependency/actions.rb', line 20

def size
  @actions.size
end