Class: QB::Util::Decorators::EnumFor
- Inherits:
-
MethodDecorators::Decorator
- Object
- MethodDecorators::Decorator
- QB::Util::Decorators::EnumFor
- Defined in:
- lib/qb/util/decorators.rb
Overview
Wrap a method that yields, returning an Enumerator if no block is given.
Implements the common "enum_for" pattern:
def f return enum_for( method ) unless block_given? yield 1 # ... end
Instance Method Summary collapse
Instance Method Details
#call(target, receiver, *args, &block) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/qb/util/decorators.rb', line 70 def call target, receiver, *args, &block if block target.call *args, &block else receiver.enum_for target.name, *args end end |