Class: MiniDefender::Rules::Default

Inherits:
MiniDefender::Rule show all
Defined in:
lib/mini_defender/rules/default.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from MiniDefender::Rule

#active?, available?, #bails?, #coerce, #error_message, #excluded?, #force_coerce?, #implicit?, #priority, #stops?, #with_message

Constructor Details

#initialize(value) ⇒ Default

Returns a new instance of Default.



4
5
6
# File 'lib/mini_defender/rules/default.rb', line 4

def initialize(value)
  @default = value
end

Class Method Details

.make(args) ⇒ Object

Raises:

  • (ArgumentError)


12
13
14
15
16
# File 'lib/mini_defender/rules/default.rb', line 12

def self.make(args)
  raise ArgumentError, 'Expected exactly one argument.' unless args.length == 1

  new(args[0])
end

.signatureObject



8
9
10
# File 'lib/mini_defender/rules/default.rb', line 8

def self.signature
  'default'
end

Instance Method Details

#default_value(validator) ⇒ Object



22
23
24
# File 'lib/mini_defender/rules/default.rb', line 22

def default_value(validator)
  @default
end

#defaults?(validator) ⇒ Boolean

Returns:



18
19
20
# File 'lib/mini_defender/rules/default.rb', line 18

def defaults?(validator)
  true
end

#message(attribute, value, validator) ⇒ Object



30
31
32
# File 'lib/mini_defender/rules/default.rb', line 30

def message(attribute, value, validator)
  "i can haz valuo?."
end

#passes?(attribute, value, validator) ⇒ Boolean

Returns:



26
27
28
# File 'lib/mini_defender/rules/default.rb', line 26

def passes?(attribute, value, validator)
  true
end