Class: Hekenga::SimpleTask

Inherits:
Object
  • Object
show all
Defined in:
lib/hekenga/simple_task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSimpleTask

Returns a new instance of SimpleTask.

[View source]

6
7
8
9
# File 'lib/hekenga/simple_task.rb', line 6

def initialize
  @ups   = []
  @downs = []
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.


5
6
7
# File 'lib/hekenga/simple_task.rb', line 5

def description
  @description
end

#downsObject (readonly)

Returns the value of attribute downs.


4
5
6
# File 'lib/hekenga/simple_task.rb', line 4

def downs
  @downs
end

#upsObject (readonly)

Returns the value of attribute ups.


4
5
6
# File 'lib/hekenga/simple_task.rb', line 4

def ups
  @ups
end

Instance Method Details

#down!Object

[View source]

21
22
23
24
25
26
# File 'lib/hekenga/simple_task.rb', line 21

def down!
  raise Hekenga::Irreversible.new(self) unless reversible?
  @downs.each do |block|
    block.call
  end
end

#reversible?Boolean

Returns:

  • (Boolean)
[View source]

28
29
30
# File 'lib/hekenga/simple_task.rb', line 28

def reversible?
  downs.any?
end

#up!(context) ⇒ Object

[View source]

15
16
17
18
19
# File 'lib/hekenga/simple_task.rb', line 15

def up!(context)
  @ups.each do |block|
    context.instance_exec(&block)
  end
end

#validate!Object

Raises:

[View source]

11
12
13
# File 'lib/hekenga/simple_task.rb', line 11

def validate!
  raise Hekenga::Invalid.new(self, :ups, "missing") unless ups.any?
end