Class: Mv::Core::Validation::BaseCollection

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

Direct Known Subclasses

Exclusion, Inclusion

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) ⇒ BaseCollection

Returns a new instance of BaseCollection.



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

def initialize(table_name, column_name, opts)
  opts = opts.is_a?(Hash) ? opts : { in: opts }

  super(table_name, column_name, opts)

  @in = opts.with_indifferent_access[:in]
end

Instance Attribute Details

#inObject (readonly)

Returns the value of attribute in.



10
11
12
# File 'lib/mv/core/validation/base_collection.rb', line 10

def in
  @in
end

Instance Method Details

#to_aObject



22
23
24
25
# File 'lib/mv/core/validation/base_collection.rb', line 22

def to_a
  prepared_in = self.in.is_a?(Range) ? range_to_a : self.in.try(:sort)
  super + [prepared_in]
end