Class: MiniDefender::Rules::DateGt

Inherits:
DateEq show all
Defined in:
lib/mini_defender/rules/date_gt.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DateEq

#initialize, make

Methods inherited from MiniDefender::Rule

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

Constructor Details

This class inherits a constructor from MiniDefender::Rules::DateEq

Class Method Details

.signatureObject



6
7
8
# File 'lib/mini_defender/rules/date_gt.rb', line 6

def self.signature
  'date_gt'
end

Instance Method Details

#message(attribute, value, validator) ⇒ Object



19
20
21
22
23
# File 'lib/mini_defender/rules/date_gt.rb', line 19

def message(attribute, value, validator)
  return "The given value is not a valid date." unless @valid_value

  "The value must be greater than #{@target_date}."
end

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

Returns:



10
11
12
13
14
15
16
17
# File 'lib/mini_defender/rules/date_gt.rb', line 10

def passes?(attribute, value, validator)
  value = parse_date(value)
  @valid_value = true

  value > @target_date
rescue ArgumentError
  false
end