module Mv::Postgresql::Validation::CheckSupport

Attributes

check_name[R]

Public Class Methods

included(mod) click to toggle source
# File lib/mv/postgresql/validation/check_support.rb, line 7
def self.included mod
  mod.validates :check_name, absence: { message: 'allowed when :as == :trigger' }, unless: :check?
end
new(table_name, column_name, opts) click to toggle source
Calls superclass method
# File lib/mv/postgresql/validation/check_support.rb, line 11
def initialize(table_name, column_name, opts)
  super

  @check_name = options.with_indifferent_access[:check_name] || default_check_name
end

Public Instance Methods

to_a() click to toggle source
Calls superclass method
# File lib/mv/postgresql/validation/check_support.rb, line 17
def to_a
  super + [check_name.to_s]
end

Protected Instance Methods

available_as() click to toggle source
Calls superclass method
# File lib/mv/postgresql/validation/check_support.rb, line 23
def available_as
  super + [:check]
end
default_as() click to toggle source
# File lib/mv/postgresql/validation/check_support.rb, line 27
def default_as
  :check 
end
default_check_name() click to toggle source
# File lib/mv/postgresql/validation/check_support.rb, line 31
def default_check_name
  "chk_mv_#{table_name}_#{column_name}"  if check?
end

Private Instance Methods

check?() click to toggle source
# File lib/mv/postgresql/validation/check_support.rb, line 37
def check?
  as.try(:to_sym) == :check
end