Sha256: 21fd4a1d35197ec75d3e1d141bbca841b3c0e79bacb1ec08ad15a87d84117f19

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

module ESA
  module Filters
    module AccountableTypeFilter
      module TransactionAccountableType
        extend ActiveSupport::Concern

        included do
          scope :with_accountable_type, lambda { |type| joins(:transaction).where(esa_transactions: {accountable_type: type}) }
          scope :excl_accountable_type, lambda { |type| joins(:transaction).where(ESA::Transaction.arel_table[:accountable_type].not_eq(type)) }
        end
      end

      module ObjectAccountableType
        extend ActiveSupport::Concern

        included do
          scope :with_accountable_type, lambda { |type| where(accountable_type: type) }
          scope :excl_accountable_type, lambda { |type| where(arel_table[:accountable_type].not_eq(type)) }
        end
      end
    end
  end
end

ESA::Amount.send :include, ESA::Filters::AccountableTypeFilter::TransactionAccountableType
ESA::Event.send :include, ESA::Filters::AccountableTypeFilter::ObjectAccountableType
ESA::Flag.send :include, ESA::Filters::AccountableTypeFilter::ObjectAccountableType
ESA::Transaction.send :include, ESA::Filters::AccountableTypeFilter::ObjectAccountableType

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
event_sourced_accounting-0.2.6 lib/esa/filters/accountable_type_filter.rb
event_sourced_accounting-0.2.4 lib/esa/filters/accountable_type_filter.rb
event_sourced_accounting-0.2.3 lib/esa/filters/accountable_type_filter.rb
event_sourced_accounting-0.2.2 lib/esa/filters/accountable_type_filter.rb