Class: Dynflow::Flows::Abstract

Inherits:
Serializable show all
Includes:
Algebrick::TypeCheck
Defined in:
lib/dynflow/flows/abstract.rb

Direct Known Subclasses

AbstractComposed, Atom

Constant Summary

Constants inherited from Serializable

Serializable::LEGACY_TIME_FORMAT, Serializable::TIME_FORMAT

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Serializable

constantize, from_hash

Constructor Details

#initializeAbstract

Returns a new instance of Abstract.



8
9
10
# File 'lib/dynflow/flows/abstract.rb', line 8

def initialize
  raise 'cannot instantiate Flows::Abstract'
end

Class Method Details

.decode(data) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/dynflow/flows/abstract.rb', line 41

def self.decode(data)
  if data.is_a? Integer
    Flows::Atom.new(data)
  else
    kind, *subflows = data
    Registry.decode(kind).new(subflows.map { |subflow| self.decode(subflow) })
  end
end

.new_from_hash(hash) ⇒ Object



36
37
38
39
# File 'lib/dynflow/flows/abstract.rb', line 36

def self.new_from_hash(hash)
  check_class_matching hash
  new(hash[:flows].map { |flow_hash| from_hash(flow_hash) })
end

Instance Method Details

#all_step_idsObject

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/dynflow/flows/abstract.rb', line 28

def all_step_ids
  raise NotImplementedError
end

#empty?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/dynflow/flows/abstract.rb', line 16

def empty?
  self.size == 0
end

#flatten!Object

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/dynflow/flows/abstract.rb', line 32

def flatten!
  raise NotImplementedError
end

#includes_step?(step_id) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/dynflow/flows/abstract.rb', line 24

def includes_step?(step_id)
  self.all_step_ids.any? { |s| s == step_id }
end

#sizeObject

Raises:

  • (NotImplementedError)


20
21
22
# File 'lib/dynflow/flows/abstract.rb', line 20

def size
  raise NotImplementedError
end

#to_hashObject



12
13
14
# File 'lib/dynflow/flows/abstract.rb', line 12

def to_hash
  { :class => self.class.name }
end