Module: BluePrint::Helper

Included in:
Integration::ActionController, Integration::Draper, Integration::Grape::Helper
Defined in:
lib/blue_print/helper.rb

Instance Method Summary collapse

Instance Method Details

#within_context_of(name_or_context, fallback = nil, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/blue_print/helper.rb', line 4

def within_context_of(name_or_context, fallback = nil, &block)
  context = BluePrint::Context.resolve(name_or_context)

  if context.active?
    block_given? && yield(BluePrint.env)
  else
    fallback.respond_to?(:call) && fallback.call(BluePrint.env)
  end
end

#without_context_of(name_or_context, fallback = nil, &block) ⇒ Object



14
15
16
# File 'lib/blue_print/helper.rb', line 14

def without_context_of(name_or_context, fallback = nil, &block)
  within_context_of(name_or_context, block, &fallback)
end