Class: ESA::SubcontextChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/esa/subcontext_checker.rb

Class Method Summary collapse

Class Method Details

.check(context, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/esa/subcontext_checker.rb', line 15

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

.providers(context, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/esa/subcontext_checker.rb', line 3

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