Sha256: 88207457513ed06c567227a1e4c135355e6b60079423dce09c95a9f9b4241ffe

Contents?: true

Size: 1.52 KB

Versions: 17

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

module LedgerSync
  module Ledgers
    module TestLedger
      class Operation
        module Mixin
          def self.included(base)
            base.include Ledgers::Operation::Mixin
            base.include InstanceMethods # To ensure these override parent methods
          end

          module InstanceMethods
            def deserialized_resource(response:)
              deserializer.deserialize(
                hash: response.body[test_ledger_resource_type.to_s.camelize],
                resource: resource
              )
            end

            def ledger_resource_path
              @ledger_resource_path ||= "#{ledger_resource_type_for_path}/#{resource.ledger_id}"
            end

            def ledger_resource_type_for_path
              test_ledger_resource_type.tr('_', '')
            end

            def response_to_operation_result(response:)
              if response.success?
                success(
                  resource: deserialized_resource(response: response),
                  response: response
                )
              else
                failure(
                  Error::OperationError.new(
                    operation: self,
                    response: response
                  )
                )
              end
            end

            def test_ledger_resource_type
              @test_ledger_resource_type ||= client.class.ledger_resource_type_for(resource_class: resource.class)
            end
          end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ledger_sync-2.6.0 lib/ledger_sync/test/support/test_ledger/operation.rb
ledger_sync-2.5.0 lib/ledger_sync/test/support/test_ledger/operation.rb
ledger_sync-2.4.4 lib/ledger_sync/test/support/test_ledger/operation.rb
ledger_sync-2.3.1 lib/ledger_sync/test/support/test_ledger/operation.rb
ledger_sync-2.2.3 lib/ledger_sync/test/support/test_ledger/operation.rb
ledger_sync-2.2.1 lib/ledger_sync/test/support/test_ledger/operation.rb
ledger_sync-2.2.0 lib/ledger_sync/test/support/test_ledger/operation.rb
ledger_sync-2.0.2 lib/ledger_sync/test/support/test_ledger/operation.rb
ledger_sync-2.0.1 lib/ledger_sync/test/support/test_ledger/operation.rb
ledger_sync-2.0.0 lib/ledger_sync/test/support/test_ledger/operation.rb
ledger_sync-2.0.0.pre.1 lib/ledger_sync/test/support/test_ledger/operation.rb
ledger_sync-1.8.1 lib/ledger_sync/test/support/test_ledger/operation.rb
ledger_sync-1.8.0 lib/ledger_sync/test/support/test_ledger/operation.rb
ledger_sync-1.7.0 lib/ledger_sync/test/support/test_ledger/operation.rb
ledger_sync-1.6.0 lib/ledger_sync/test/support/test_ledger/operation.rb
ledger_sync-1.5.2 lib/ledger_sync/test/support/test_ledger/operation.rb
ledger_sync-1.5.1 lib/ledger_sync/test/support/test_ledger/operation.rb