module Dicer::Contextable

Public Instance Methods

as(role, context, &block) click to toggle source
# File lib/dicer/contextable.rb, line 13
def as(role, context, &block)
  if block.nil?
    context.supply(self, role)
  else
    block.call(context.supply(self, role))
  end
end
as_with_dicer(role, context = Dicer::Context.current, &block) click to toggle source
# File lib/dicer/railtie/contextable.rb, line 10
def as_with_dicer(role, context = Dicer::Context.current, &block)
  as_without_dicer(role, context, &block)
end
behaves_like(*behaviors, &block) click to toggle source
# File lib/dicer/contextable.rb, line 21
def behaves_like(*behaviors, &block)
  delegator = Dicer::Delegator.make(self.class, behaviors)

  block.nil? ? delegator.new(self) : block.call(delegator.new(self))
end
in_context(context, &block) click to toggle source
# File lib/dicer/contextable.rb, line 5
def in_context(context, &block)
  if block.nil?
    context.supply(self)
  else
    block.call(context.supply(self))
  end
end
in_context_with_dicer(context = Dicer::Context.current, &block) click to toggle source
# File lib/dicer/railtie/contextable.rb, line 5
def in_context_with_dicer(context = Dicer::Context.current, &block)
  in_context_without_dicer(context, &block)
end