Sha256: 52b15b5d549e40ab4508a0e3e2ea88376f37d0368fe882724d871bd19a89d733

Contents?: true

Size: 1019 Bytes

Versions: 5

Compression:

Stored size: 1019 Bytes

Contents

module LedgerSync
  module Adaptors
    module Test
      class Adaptor < LedgerSync::Adaptors::Adaptor
        def initialize(*_config); end

        def find(resource:, id:)
          { 'id' => id }
        end

        def query(resource:, query:)
          resource_klass = LedgerSync.resources[resource.to_sym]

          Array.new(2) do |i|
            ret = {
              'id' => SecureRandom.uuid,
            }

            ret['name'] = "Test #{resource} #{i}" if resource_klass.instance_methods.include?(:name=)
            ret
          end
        end

        def refresh!
          self
        end

        def upsert(resource:, payload:)
          payload
        end

        def url_for(resource:)
          case resource
          when LedgerSync::Customer
            "http://example.com/customer/#{resource.ledger_id}"
          else
            raise NotImplementedError
          end
        end

        def self.ledger_attributes_to_save
          []
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ledger_sync-1.0.10 lib/ledger_sync/adaptors/test/adaptor.rb
ledger_sync-1.0.9 lib/ledger_sync/adaptors/test/adaptor.rb
ledger_sync-1.0.3 lib/ledger_sync/adaptors/test/adaptor.rb
ledger_sync-1.0.2 lib/ledger_sync/adaptors/test/adaptor.rb
ledger_sync-1.0.0 lib/ledger_sync/adaptors/test/adaptor.rb