Sha256: afc8d882631f2ea2e7020188f442ae50f56f6a960a54476fc363cc3ba283611d
Contents?: true
Size: 716 Bytes
Versions: 7
Compression:
Stored size: 716 Bytes
Contents
# frozen_string_literal: true module CoinsPaid class Address module Types include Dry.Types() end class Data < Dry::Struct attribute :foreign_id, Types::Coercible::String attribute :currency, Types::String attribute :convert_to, Types::String end include Dry::Initializer.define -> do param :request_data, Data end def call ActiveRecord::Base.transaction do CoinsPaidAddress.lock.find_or_create_by!(request_data.attributes.slice(:foreign_id, :currency)) do |address| response = CoinsPaid::API.take_address(request_data.attributes) address.assign_attributes(response.attributes) end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems