Class: ValidatesDateTime::ValidatesDateTimeRestriction
- Inherits:
-
Struct
- Object
- Struct
- ValidatesDateTime::ValidatesDateTimeRestriction
- Defined in:
- lib/validates_date_time.rb
Instance Attribute Summary collapse
-
#parse_method ⇒ Object
Returns the value of attribute parse_method.
-
#raw_value ⇒ Object
Returns the value of attribute raw_value.
Instance Method Summary collapse
Instance Attribute Details
#parse_method ⇒ Object
Returns the value of attribute parse_method
21 22 23 |
# File 'lib/validates_date_time.rb', line 21 def parse_method @parse_method end |
#raw_value ⇒ Object
Returns the value of attribute raw_value
21 22 23 |
# File 'lib/validates_date_time.rb', line 21 def raw_value @raw_value end |
Instance Method Details
#last_value ⇒ Object
39 40 41 |
# File 'lib/validates_date_time.rb', line 39 def last_value @last_value end |
#parse(string) ⇒ Object
35 36 37 |
# File 'lib/validates_date_time.rb', line 35 def parse(string) ActiveRecord::ConnectionAdapters::Column.send("string_to_#{parse_method}", string) end |
#to_s ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/validates_date_time.rb', line 43 def to_s if raw_value.is_a?(Symbol) raw_value.to_s.humanize else @last_value.to_s end end |
#value(record) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/validates_date_time.rb', line 22 def value(record) @last_value = case raw_value when Symbol record.send(raw_value) when Proc raw_value.call(record) else raw_value end @last_value = parse(@last_value) end |