Class: Gutentag::TagValidations

Inherits:
Object
  • Object
show all
Defined in:
lib/gutentag/tag_validations.rb

Constant Summary collapse

DEFAULTS =
{
  :presence   => true,
  :uniqueness => {:case_sensitive => false}
}.freeze
DATABASE_ERROR_CLASSES =
lambda {
  classes = []
  if ActiveRecord::VERSION::STRING.to_f > 4.0
    classes << ActiveRecord::NoDatabaseError
  end
  classes << ActiveRecord::ConnectionNotEstablished
  classes << Mysql2::Error     if defined?(::Mysql2)
  classes << PG::ConnectionBad if defined?(::PG)
  classes
}.call.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ TagValidations

Returns a new instance of TagValidations.



26
27
28
# File 'lib/gutentag/tag_validations.rb', line 26

def initialize(klass)
  @klass = klass
end

Class Method Details

.call(klass) ⇒ Object



22
23
24
# File 'lib/gutentag/tag_validations.rb', line 22

def self.call(klass)
  new(klass).call
end

Instance Method Details

#callObject



30
31
32
# File 'lib/gutentag/tag_validations.rb', line 30

def call
  klass.validates :name, validation_options.dup
end