Sha256: a1f41c0057307770a8dbc3b68b16744fb8e57c7b82fcfe121baddd3575d99d11

Contents?: true

Size: 988 Bytes

Versions: 8

Compression:

Stored size: 988 Bytes

Contents

# frozen_string_literal: true

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

      module InstanceMethods
        def ledger_resource_path
          @ledger_resource_path ||= [
            ledger_namespace_path,
            ledger_resource_type.pluralize,
            resource.ledger_id
          ].compact.join('/')
        end

        def ledger_namespace_path
          @ledger_namespace_path ||= nil
        end

        def deserialized_resource
          deserializer.deserialize(
            hash: response.body[ledger_resource_type],
            resource: resource
          )
        end

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
desertcart-1.2.0 lib/desertcart/operation.rb
desertcart-1.1.5 lib/desertcart/operation.rb
desertcart-1.1.4 lib/desertcart/operation.rb
desertcart-1.1.3 lib/desertcart/operation.rb
desertcart-1.1.2 lib/desertcart/operation.rb
desertcart-1.1.1 lib/desertcart/operation.rb
desertcart-1.1.0 lib/desertcart/operation.rb
desertcart-1.0.0 lib/desertcart/operation.rb