module Dataflow::Node
Define (default) common interface for nodes. These may be overriden with their specific implementations.
Public Class Methods
find(id)
click to toggle source
Returns either a DataNode or a ComputeNode that match the id
# File lib/dataflow/node.rb, line 7 def self.find(id) begin return Dataflow::Nodes::DataNode.find(id) rescue Mongoid::Errors::DocumentNotFound # try again against a computed node end Dataflow::Nodes::ComputeNode.find(id) end
Public Instance Methods
all_dependencies()
click to toggle source
# File lib/dataflow/node.rb, line 33 def all_dependencies [] end
metadata()
click to toggle source
# File lib/dataflow/node.rb, line 43 def metadata metadata = { _id: self._id, _type: self._type, } properties_data = self.class.properties.keys.map do |property_name| value = self[property_name] [property_name, value] end.to_h metadata.merge(properties_data) end
recompute(*args)
click to toggle source
# File lib/dataflow/node.rb, line 17 def recompute(*args) # Interface only, for recursion purposes end
required_by()
click to toggle source
# File lib/dataflow/node.rb, line 37 def required_by Dataflow::Nodes::ComputeNode.where(dependency_ids: _id).map { |node| { node: node, type: 'dependency' } } end
valid_for_computation?()
click to toggle source
Overriden in computed node
# File lib/dataflow/node.rb, line 22 def valid_for_computation? true end
validate!()
click to toggle source
# File lib/dataflow/node.rb, line 26 def validate! # throw if normal model validation do not pass. valid = valid_for_computation? raise Dataflow::Errors::InvalidConfigurationError, errors.messages unless valid true end