class PGTrunk::Operations::Statistics::Base
@abstract @private Base
class for operations with check constraints
Public Instance Methods
column(name)
click to toggle source
# File lib/pg_trunk/operations/statistics/base.rb, line 20 def column(name) columns << name.strip end
expression(text)
click to toggle source
Methods to populate multivariable attributes from a block
# File lib/pg_trunk/operations/statistics/base.rb, line 16 def expression(text) expressions << text.strip end
Private Instance Methods
custom_name?(qname = name)
click to toggle source
# File lib/pg_trunk/operations/statistics/base.rb, line 83 def custom_name?(qname = name) qname&.differs_from?(/^stat_rails_\w+$/) end
generated_name()
click to toggle source
# File lib/pg_trunk/operations/statistics/base.rb, line 72 def generated_name return if table.blank? || parts.blank? @generated_name ||= begin key_options = { kinds: kinds, parts: parts } identifier = "#{table.lean}_#{key_options}_stat" hashed_identifier = Digest::SHA256.hexdigest(identifier).first(10) PGTrunk::QualifiedName.wrap("stat_rails_#{hashed_identifier}") end end
parts()
click to toggle source
# File lib/pg_trunk/operations/statistics/base.rb, line 87 def parts @parts ||= [ *columns.reject(&:blank?).map(&:inspect), *expressions.reject(&:blank?).map { |ex| "(#{ex})" }, ] end