Sha256: f26c7c4ddc8e832b2dda4651ef11094afa33c3a6f34da3229d4cad1e912b5542
Contents?: true
Size: 1.25 KB
Versions: 26
Compression:
Stored size: 1.25 KB
Contents
module PgGraph::Data # Dimension of the node (corresponding kind shown in parenthesis): # # 0 A single value (:value) # 1 A single record (:record) # 2 A map from id to record (:table) # 3 A map from id to array of duplicate records (:table) # # The dimension defines class and structures of GraphData objects # class Dimension def self.valid?(dimension, min: 0) dimension.is_a?(Integer) && (min..3).include?(dimension) end def self.kind(dimension) case dimension when 0; :value when 1; :record when 2, 3; :table end end def self.field_class(dimension) validate(dimension) case dimension when 0; Column when 1; RecordField when 2; TableField when 3; MmTableField end end def self.value_class(dimension) validate(dimension, min: 1) case dimension when 1; RecordValue when 2; TableValue when 3; MmTableValue end end def self.validate(dim, min: 0, unwind: 1) constrain dim, Integer, unwind: unwind constrain dim, lambda { |d| Dimension.valid?(d, min: min) }, "Out of range value: #{dim}", unwind: unwind end end end
Version data entries
26 entries across 26 versions & 1 rubygems