Class: MiniDefender::Rules::In
Class Method Summary
collapse
Instance Method Summary
collapse
#active?, available?, #bails?, #coerce, #default_value, #defaults?, #error_message, #excluded?, #force_coerce?, #implicit?, #priority, #stops?, #with_message
Constructor Details
#initialize(values) ⇒ In
Returns a new instance of In.
4
5
6
7
8
|
# File 'lib/mini_defender/rules/in.rb', line 4
def initialize(values)
raise ArgumentError, 'Expected an array of values.' unless values.is_a?(Array)
@values = values
end
|
Class Method Details
.make(args) ⇒ Object
14
15
16
17
18
|
# File 'lib/mini_defender/rules/in.rb', line 14
def self.make(args)
raise ArgumentError, 'Expected at least one argument.' unless args.length > 0
new(args)
end
|
.signature ⇒ Object
10
11
12
|
# File 'lib/mini_defender/rules/in.rb', line 10
def self.signature
'in'
end
|
Instance Method Details
#message(attribute, value, validator) ⇒ Object
24
25
26
|
# File 'lib/mini_defender/rules/in.rb', line 24
def message(attribute, value, validator)
"The value must be one of #{@values.to_sentence}."
end
|
#passes?(attribute, value, validator) ⇒ Boolean
20
21
22
|
# File 'lib/mini_defender/rules/in.rb', line 20
def passes?(attribute, value, validator)
@values.include?(value)
end
|