Class: Operaton::Bpm::Client::Variable::Impl::Mapper::DateValueMapper
- Inherits:
-
PrimitiveValueMapper
- Object
- AbstractTypedValueMapper
- PrimitiveValueMapper
- Operaton::Bpm::Client::Variable::Impl::Mapper::DateValueMapper
- Defined in:
- lib/operaton/bpm/client/variable/impl/mapper/date_value_mapper.rb
Overview
Mirrors org.operaton.bpm.client.variable.impl.mapper.DateValueMapper. The date format is a Ruby strftime pattern.
Instance Attribute Summary
Attributes inherited from AbstractTypedValueMapper
Instance Method Summary collapse
- #convert_to_typed_value(untyped_value) ⇒ Object
-
#initialize(date_format) ⇒ DateValueMapper
constructor
A new instance of DateValueMapper.
- #read_typed_value(typed_value_field) ⇒ Object
- #write_value(date_value, typed_value_field) ⇒ Object
Methods inherited from PrimitiveValueMapper
Methods inherited from AbstractTypedValueMapper
#can_handle_typed_value, #can_handle_typed_value_field, #serialization_dataformat, #type
Methods included from ValueMapper
#can_handle_typed_value, #can_handle_typed_value_field, #read_value, #serialization_dataformat, #type
Constructor Details
#initialize(date_format) ⇒ DateValueMapper
Returns a new instance of DateValueMapper.
17 18 19 20 |
# File 'lib/operaton/bpm/client/variable/impl/mapper/date_value_mapper.rb', line 17 def initialize(date_format) super(Engine::Variable::ValueType::DATE) @date_format = date_format end |
Instance Method Details
#convert_to_typed_value(untyped_value) ⇒ Object
22 23 24 |
# File 'lib/operaton/bpm/client/variable/impl/mapper/date_value_mapper.rb', line 22 def convert_to_typed_value(untyped_value) Engine::Variable::Variables.date_value(to_time(untyped_value.value)) end |
#read_typed_value(typed_value_field) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/operaton/bpm/client/variable/impl/mapper/date_value_mapper.rb', line 26 def read_typed_value(typed_value_field) date = nil value = typed_value_field.value unless value.nil? begin date = Time.strptime(value, @date_format) rescue ArgumentError => e raise Client::Impl::ExternalTaskClientLogger.client_logger .value_mapper_exception_while_parsing_date(value, e) end end Engine::Variable::Variables.date_value(date) end |
#write_value(date_value, typed_value_field) ⇒ Object
40 41 42 43 |
# File 'lib/operaton/bpm/client/variable/impl/mapper/date_value_mapper.rb', line 40 def write_value(date_value, typed_value_field) date = date_value.value typed_value_field.value = to_time(date).strftime(@date_format) unless date.nil? end |