Class: Mv::Core::Validation::Uniqueness

Inherits:
Base
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/mv/core/validation/uniqueness.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#allow_blank, #allow_nil, #as, #column_name, #create_trigger_name, #message, #on, #options, #table_name, #update_trigger_name

Instance Method Summary collapse

Methods inherited from Base

#<=>, #create?, #full_message, #update?

Constructor Details

#initialize(table_name, column_name, opts) ⇒ Uniqueness

Returns a new instance of Uniqueness.



13
14
15
16
17
18
19
# File 'lib/mv/core/validation/uniqueness.rb', line 13

def initialize(table_name, column_name, opts)
  opts = opts == true ? {} : opts

  super(table_name, column_name, opts)

  @index_name = opts.with_indifferent_access[:index_name] || default_index_name
end

Instance Attribute Details

#index_nameObject (readonly)

Returns the value of attribute index_name.



9
10
11
# File 'lib/mv/core/validation/uniqueness.rb', line 9

def index_name
  @index_name
end

Instance Method Details

#to_aObject



21
22
23
# File 'lib/mv/core/validation/uniqueness.rb', line 21

def to_a
  super + [index_name.to_s]
end