# This module creates a formalized way to facilitate collection lookups.
# The default convention is that every workflow model has an associated
# collection with it:
#   WorkflowInstance::Scenario1::Collection
#   WorkflowInstance::Scenario2::Collection
#   OwnerInitialization::Scenario1::Collection
#   etc...
# But since we should be ready for unforseen circumstances a lookup method
# should be used in stead of a hard namespace lookup.
module Dunlop::CollectionLookup
  extend ActiveSupport::Concern

  # conveniance and proper code smell implementation to avoid self.class
  # calls in places where it does not belong
  def collection_class
    self.class.collection
  end

  module ClassMethods
    # conveniance and proper code smell implementation to avoid self::Collection
    # calls in places where it does not belong
    def collection
      self::Collection
    end
  end
end
