Class: MiniDefender::Rules::Array
Class Method Summary
collapse
Instance Method Summary
collapse
#active?, available?, #bails?, #default_value, #defaults?, #error_message, #excluded?, #implicit?, #stops?, #with_message
Constructor Details
#initialize(data_mode = 'none') ⇒ Array
Returns a new instance of Array.
8
9
10
|
# File 'lib/mini_defender/rules/array.rb', line 8
def initialize(data_mode = 'none')
@data_mode = data_mode
end
|
Class Method Details
.make(args) ⇒ Object
12
13
14
|
# File 'lib/mini_defender/rules/array.rb', line 12
def self.make(args)
new(args[0] || 'none')
end
|
.signature ⇒ Object
4
5
6
|
# File 'lib/mini_defender/rules/array.rb', line 4
def self.signature
'array'
end
|
Instance Method Details
#coerce(value) ⇒ Object
20
21
22
|
# File 'lib/mini_defender/rules/array.rb', line 20
def coerce(value)
@data_mode == 'all' ? value : []
end
|
#force_coerce? ⇒ Boolean
24
25
26
|
# File 'lib/mini_defender/rules/array.rb', line 24
def force_coerce?
true
end
|
#message(attribute, value, validator) ⇒ Object
32
33
34
|
# File 'lib/mini_defender/rules/array.rb', line 32
def message(attribute, value, validator)
"The field must be an array."
end
|
#passes?(attribute, value, validator) ⇒ Boolean
28
29
30
|
# File 'lib/mini_defender/rules/array.rb', line 28
def passes?(attribute, value, validator)
value.is_a?(Array)
end
|
#priority ⇒ Object
16
17
18
|
# File 'lib/mini_defender/rules/array.rb', line 16
def priority
500
end
|