Sha256: 89094abccff20feec7f3b2152f873b74b8770b54a8a4366db8902c4b85420355

Contents?: true

Size: 1017 Bytes

Versions: 5

Compression:

Stored size: 1017 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 post(resource:, payload:)
          payload
        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 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.3.2 lib/ledger_sync/adaptors/test/adaptor.rb
ledger_sync-1.3.1 lib/ledger_sync/adaptors/test/adaptor.rb
ledger_sync-1.1.3 lib/ledger_sync/adaptors/test/adaptor.rb
ledger_sync-1.1.2 lib/ledger_sync/adaptors/test/adaptor.rb
ledger_sync-1.1.1 lib/ledger_sync/adaptors/test/adaptor.rb