Sha256: 136bbe80e538342c9416fb8ae983d16e96fe7482a996d88533233f18ac7c9a1a

Contents?: true

Size: 767 Bytes

Versions: 4

Compression:

Stored size: 767 Bytes

Contents

module ESA
  module ContextProviders
    class AccountableContextProvider < ESA::ContextProvider
      def self.provided_types
        ["ESA::Contexts::AccountableContext"]
      end

      def self.context_id(context, options = {})
        [context.accountable_id, context.accountable_type]
      end

      def self.contained_ids(context, options = {})
        context.transactions.pluck([:accountable_id, :accountable_type]).uniq
      end

      def self.instantiate(parent, namespace, id, options = {})
        accountable_id, accountable_type = id
        ESA::Contexts::AccountableContext.new(chart_id: parent.chart_id, parent_id: parent.id, namespace: namespace, accountable_id: accountable_id, accountable_type: accountable_type)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
event_sourced_accounting-0.1.4 lib/esa/context_providers/accountable_context_provider.rb
event_sourced_accounting-0.1.3 lib/esa/context_providers/accountable_context_provider.rb
event_sourced_accounting-0.1.1 lib/esa/context_providers/accountable_context_provider.rb
event_sourced_accounting-0.1.0 app/models/esa/context_providers/accountable_context_provider.rb