Class: Mv::Core::Validation::Base
- Inherits:
-
Object
- Object
- Mv::Core::Validation::Base
- Includes:
- ActiveModel::Validations, Comparable
- Defined in:
- lib/mv/core/validation/base.rb
Direct Known Subclasses
Absence, BaseCollection, Custom, Length, Presence, Uniqueness
Instance Attribute Summary collapse
-
#allow_blank ⇒ Object
readonly
Returns the value of attribute allow_blank.
-
#allow_nil ⇒ Object
readonly
Returns the value of attribute allow_nil.
-
#as ⇒ Object
readonly
Returns the value of attribute as.
-
#column_name ⇒ Object
readonly
Returns the value of attribute column_name.
-
#create_trigger_name ⇒ Object
readonly
Returns the value of attribute create_trigger_name.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#on ⇒ Object
readonly
Returns the value of attribute on.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
-
#update_trigger_name ⇒ Object
readonly
Returns the value of attribute update_trigger_name.
Instance Method Summary collapse
- #<=>(other_validation) ⇒ Object
- #create? ⇒ Boolean
- #full_message ⇒ Object
-
#initialize(table_name, column_name, options) ⇒ Base
constructor
A new instance of Base.
- #to_a ⇒ Object
- #update? ⇒ Boolean
Constructor Details
#initialize(table_name, column_name, options) ⇒ Base
Returns a new instance of Base.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mv/core/validation/base.rb', line 19 def initialize table_name, column_name, @table_name = table_name @column_name = column_name @options = .with_indifferent_access.tap do || @message = [:message] || @as = [:as] || default_as @on = [:on] || default_on @create_trigger_name = [:create_trigger_name] || default_create_trigger_name @update_trigger_name = [:update_trigger_name] || default_update_trigger_name @allow_nil = [:allow_nil].nil? ? default_allow_nil : [:allow_nil] @allow_blank = [:allow_blank].nil? ? default_allow_blank : [:allow_blank] end end |
Instance Attribute Details
#allow_blank ⇒ Object (readonly)
Returns the value of attribute allow_blank.
8 9 10 |
# File 'lib/mv/core/validation/base.rb', line 8 def allow_blank @allow_blank end |
#allow_nil ⇒ Object (readonly)
Returns the value of attribute allow_nil.
8 9 10 |
# File 'lib/mv/core/validation/base.rb', line 8 def allow_nil @allow_nil end |
#as ⇒ Object (readonly)
Returns the value of attribute as.
8 9 10 |
# File 'lib/mv/core/validation/base.rb', line 8 def as @as end |
#column_name ⇒ Object (readonly)
Returns the value of attribute column_name.
8 9 10 |
# File 'lib/mv/core/validation/base.rb', line 8 def column_name @column_name end |
#create_trigger_name ⇒ Object (readonly)
Returns the value of attribute create_trigger_name.
8 9 10 |
# File 'lib/mv/core/validation/base.rb', line 8 def create_trigger_name @create_trigger_name end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
8 9 10 |
# File 'lib/mv/core/validation/base.rb', line 8 def @message end |
#on ⇒ Object (readonly)
Returns the value of attribute on.
8 9 10 |
# File 'lib/mv/core/validation/base.rb', line 8 def on @on end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/mv/core/validation/base.rb', line 8 def @options end |
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
8 9 10 |
# File 'lib/mv/core/validation/base.rb', line 8 def table_name @table_name end |
#update_trigger_name ⇒ Object (readonly)
Returns the value of attribute update_trigger_name.
8 9 10 |
# File 'lib/mv/core/validation/base.rb', line 8 def update_trigger_name @update_trigger_name end |
Instance Method Details
#<=>(other_validation) ⇒ Object
40 41 42 |
# File 'lib/mv/core/validation/base.rb', line 40 def <=> other_validation [self.class.name, to_a] <=> [other_validation.class.name, other_validation.to_a] end |
#create? ⇒ Boolean
48 49 50 |
# File 'lib/mv/core/validation/base.rb', line 48 def create? [:save, :create].include?(on.try(:to_sym)) end |
#full_message ⇒ Object
52 53 54 |
# File 'lib/mv/core/validation/base.rb', line 52 def () end |
#to_a ⇒ Object
35 36 37 38 |
# File 'lib/mv/core/validation/base.rb', line 35 def to_a [table_name.to_s, column_name.to_s, .to_s, on.to_s, create_trigger_name.to_s, update_trigger_name.to_s, allow_nil, allow_blank, as.to_s] end |
#update? ⇒ Boolean
44 45 46 |
# File 'lib/mv/core/validation/base.rb', line 44 def update? [:save, :update].include?(on.try(:to_sym)) end |