Sha256: 7dcc96015331f4d890d9fe7b08a34f5355bcff20e7ab256c992566df2ca674a8
Contents?: true
Size: 1.17 KB
Versions: 2
Compression:
Stored size: 1.17 KB
Contents
module Tufy class BuildIdSegment < BuildSegment expects :raw_data promises :transformed_data REQUIRED_KEYS = [ :id_number, :id_type, ] executed do |ctx| # ID Segment is not required. # If ID type passed here does # not exist, do not proceed. # TODO: Testing validate_presence_of_required_keys(ctx.raw_data, REQUIRED_KEYS) if id_type_exists?(ctx.raw_data[:id_type]) ctx.transformed_data = ctx.transformed_data + transform(ctx).upcase end end private def self.transform(ctx) raw_data = ctx[:raw_data] result = with(ctx).reduce( Fields::Id::BuildIdNumberField, Fields::Id::BuildIdTypeField, ) Constants::SEGMENT_TAG + result[:transformed_data] end def self.id_type_exists?(id_type) Constants::ID_TYPES.include?(id_type) end module Constants # tags SEGMENT_TAG = "ID03I01" ID_NUMBER_TAG = "01" ID_TYPE_TAG = "02" # id type constants SSS = "SSS" PP = "PP" TIN = "TIN" DL = "DL" GSIS = "GSIS" UMID = "UMID" ID_TYPES = [SSS, PP, TIN, DL, GSIS, UMID] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tufy-0.0.8 | lib/tufy/build_id_segment.rb |
tufy-0.0.7 | lib/tufy/build_id_segment.rb |