Sha256: e3ad710450ec99ed7bf60b9d5244519d7fdd297c66e7e536c81fd965c4810300
Contents?: true
Size: 638 Bytes
Versions: 1
Compression:
Stored size: 638 Bytes
Contents
# frozen_string_literal: true class Gutentag::TagValidations DEFAULTS = { :presence => true, :uniqueness => {:case_sensitive => false} }.freeze def self.call(klass) new(klass).call end def initialize(klass) @klass = klass end def call klass.validates :name, validation_options end private attr_reader :klass def add_length_validation? klass.table_exists? && limit.present? end def limit @limit ||= klass.columns_hash["name"].limit end def validation_options return DEFAULTS unless add_length_validation? DEFAULTS.merge :length => {:maximum => limit} end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gutentag-2.0.0 | lib/gutentag/tag_validations.rb |