Sha256: 779cd382a068e47c5605ac4e693f029fbcf23332d65b14b2a8e0c6a9006464d2
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
require 'builder' module Arbetsformedlingen PacketSchema = Dry::Validation.Form do configure do config.type_specs = true config.messages_file = File.expand_path('../../../../config/locales/errors.yml', __FILE__) predicates(Predicates) end required(:active, Types::Bool).filled required(:job_id, Types::StrippedString).filled required(:id, Types::StrippedString).filled required(:number_to_fill, Types::Int).filled(gt?: 0) required(:ssyk_id, Types::Int).filled(:ssyk_id?) end class Packet < Model DEFAULT_PACKET_ID = 1 def initialize(attributes:, publication:, document:, position:) hash = attributes @publication = publication @document = document @position = position id = hash.fetch(:id, DEFAULT_PACKET_ID) super(PacketSchema.call(hash.merge(id: id))) end def to_h hash = super hash[:publication] = @publication.to_h hash[:document] = @document.to_h hash[:position] = @position.to_h hash end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
arbetsformedlingen-0.1.0 | lib/arbetsformedlingen/models/packet.rb |