Sha256: 351f00f4d9d73327630bcc165d0dfde2f9dbcb0b03eccce338dd523a668504c9

Contents?: true

Size: 735 Bytes

Versions: 4

Compression:

Stored size: 735 Bytes

Contents

module ESA
  module Contexts
    class AccountableContext < ESA::Context
      attr_accessible :accountable, :accountable_id, :accountable_type
      attr_readonly   :accountable, :accountable_id, :accountable_type

      belongs_to :accountable, :polymorphic => true

      validates_presence_of :accountable

      protected

      def default_name
        "#{self.accountable_type} #{self.accountable_id}" unless self.accountable_type.nil?
      end

      def initialize_filters
        @filters = []

        if self.accountable_id.present? and self.accountable_type.present?
          @filters << lambda { |relation| relation.with_accountable(self.accountable_id, self.accountable_type) }
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
event_sourced_accounting-0.2.6 app/models/esa/contexts/accountable_context.rb
event_sourced_accounting-0.2.4 app/models/esa/contexts/accountable_context.rb
event_sourced_accounting-0.2.3 app/models/esa/contexts/accountable_context.rb
event_sourced_accounting-0.2.2 app/models/esa/contexts/accountable_context.rb