Sha256: 399beaf3e030d2612993a323b4d5cdc2a89f1d8f77125d59395b4fec7e9ff92a

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

module ESA
  class SubcontextChecker
    def self.providers(context, options = {})
      if :namespace.in? options
        if options[:namespace].respond_to? :each
          ESA.configuration.context_providers.slice(*options[:namespace])
        else
          ESA.configuration.context_providers.slice("#{options[:namespace]}")
        end
      else
        ESA.configuration.context_providers_for_path(context.effective_path)
      end
    end

    def self.check(context, options = {})
      providers(context, options).each do |namespace,provider|
        if provider.is_a? Class and provider.respond_to? :check_subcontexts
          provider.check_subcontexts(context, namespace)
        elsif provider.respond_to? :count and provider.count == 2 and
              provider[0].is_a? Class and provider[0].respond_to? :check_subcontexts and provider[1].is_a? Hash
          provider_klass, provider_options = provider
          provider_klass.check_subcontexts(context, namespace, provider_options)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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