Module: Dicer::Contextable
- Included in:
- ActiveRecord
- Defined in:
- lib/dicer/contextable.rb,
lib/dicer/railtie/contextable.rb
Instance Method Summary collapse
- #as(*behaviors, &block) ⇒ Object
- #in_context(context, &block) ⇒ Object
- #in_context_with_dicer(context = Dicer::Context.current, &block) ⇒ Object
Instance Method Details
#as(*behaviors, &block) ⇒ Object
13 14 15 16 17 |
# File 'lib/dicer/contextable.rb', line 13 def as(*behaviors, &block) delegator = Dicer::Delegator.make(self.class, behaviors) block.nil? ? delegator.new(self) : block.call(delegator.new(self)) end |
#in_context(context, &block) ⇒ Object
5 6 7 8 9 10 11 |
# 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 |