Class: Datev::BooleanField
- Inherits:
-
Field
- Object
- Field
- Datev::BooleanField
show all
- Defined in:
- lib/datev/field/boolean_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
#output(value, _context = nil) ⇒ Object
11
12
13
|
# File 'lib/datev/field/boolean_field.rb', line 11
def output(value, _context=nil)
value ? 1 : 0 unless value.nil?
end
|
#validate!(value) ⇒ Object
3
4
5
6
7
8
9
|
# File 'lib/datev/field/boolean_field.rb', line 3
def validate!(value)
super
unless value.nil?
raise ArgumentError.new("Value given for field '#{name}' is not a Boolean") unless [true, false].include?(value)
end
end
|