Class: Datev::DateField
- Inherits:
-
Field
- Object
- Field
- Datev::DateField
show all
- Defined in:
- lib/datev/field/date_field.rb
Instance Attribute Summary
Attributes inherited from Field
#block, #name, #options
Instance Method Summary
collapse
Methods inherited from Field
#initialize, #required?
Constructor Details
This class inherits a constructor from Datev::Field
Instance Method Details
3
4
5
|
# File 'lib/datev/field/date_field.rb', line 3
def format
options[:format]
end
|
#output(value, _context = nil) ⇒ Object
15
16
17
|
# File 'lib/datev/field/date_field.rb', line 15
def output(value, _context=nil)
value.strftime(format) if value
end
|
#validate!(value) ⇒ Object
7
8
9
10
11
12
13
|
# File 'lib/datev/field/date_field.rb', line 7
def validate!(value)
super
if value
raise ArgumentError.new("Value given for field '#{name}' is not a Date or Time") unless value.is_a?(Time) || value.is_a?(Date)
end
end
|