Class: Deptree::Dependency::Actions
- Inherits:
-
Object
- Object
- Deptree::Dependency::Actions
- Defined in:
- lib/deptree/dependency/actions.rb
Instance Method Summary collapse
- #add(name, behaviour) ⇒ Object
- #find(name) ⇒ Object
-
#initialize(dependency) ⇒ Actions
constructor
A new instance of Actions.
- #size ⇒ Object
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 |
#size ⇒ Object
20 21 22 |
# File 'lib/deptree/dependency/actions.rb', line 20 def size @actions.size end |