Class: Tengine::Job::Template::Vertex
- Inherits:
-
Object
- Object
- Tengine::Job::Template::Vertex
show all
- Includes:
- Mongoid::Document, Mongoid::Timestamps, Structure::NamePath, Structure::Tree, Structure::Visitor::Accepter
- Defined in:
- lib/tengine/job/template/vertex.rb
Overview
Edgeとともにジョブネットを構成するグラフの「頂点」を表すモデル
自身がツリー構造を
Defined Under Namespace
Classes: VertexValidations
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.create!(*args, &block) ⇒ Object
70
71
72
|
# File 'lib/tengine/job/template/vertex.rb', line 70
def create!(*args, &block)
raise_flatten_errors{ super(*args, &block) }
end
|
.flatten_errors(vertex, dest = nil) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/tengine/job/template/vertex.rb', line 50
def flatten_errors(vertex, dest = nil)
dest ||= []
children_errors = vertex.errors.messages.delete(:children)
edges_errors = vertex.errors.messages.delete(:edges)
vertex.errors.full_messages.each{|msg| dest << "#{vertex.name_path} #{msg}"}
vertex.children.each{|child| flatten_errors(child, dest)}
if vertex.respond_to?(:edges)
vertex.edges.each do|edge|
edge.errors.full_messages.each{|msg| dest << "#{edge.name_for_message} #{msg}"}
end
end
dest
end
|
.raise_flatten_errors ⇒ Object
64
65
66
67
68
|
# File 'lib/tengine/job/template/vertex.rb', line 64
def raise_flatten_errors
yield if block_given?
rescue Mongoid::Errors::Validations => e
raise VertexValidations, e.document
end
|
Instance Method Details
#generate(options = {}) ⇒ Object
94
95
96
|
# File 'lib/tengine/job/template/vertex.rb', line 94
def generate(options = {})
Tengine::Job::Template::Generator.new.execute(self, options)
end
|
#next_edges ⇒ Object
88
89
90
91
|
# File 'lib/tengine/job/template/vertex.rb', line 88
def next_edges
return nil unless parent
parent.edges.select{|edge| edge.origin_id == self.id}
end
|
#previous_edges ⇒ Object
Also known as:
prev_edges
82
83
84
85
|
# File 'lib/tengine/job/template/vertex.rb', line 82
def previous_edges
return nil unless parent
parent.edges.select{|edge| edge.destination_id == self.id}
end
|
#runtime? ⇒ Boolean
39
|
# File 'lib/tengine/job/template/vertex.rb', line 39
def runtime?; !template?; end
|
#save!(*args) ⇒ Object
75
76
77
|
# File 'lib/tengine/job/template/vertex.rb', line 75
def save!(*args)
self.class.raise_flatten_errors{ super(*args) }
end
|
#template? ⇒ Boolean
def short_inspect
"#<%%%-30s id: %s>" % [self.class.name, self.id.to_s]
end
alias_method :long_inspect, :inspect
alias_method :inspect, :short_inspect
38
|
# File 'lib/tengine/job/template/vertex.rb', line 38
def template?; true; end
|
#update_attributes!(*args) ⇒ Object
78
79
80
|
# File 'lib/tengine/job/template/vertex.rb', line 78
def update_attributes!(*args)
self.class.raise_flatten_errors{ super(*args) }
end
|