Class: Gracefully::Command
- Inherits:
-
Object
- Object
- Gracefully::Command
- Defined in:
- lib/gracefully/command.rb
Direct Known Subclasses
RetriedCommand, ShortCircuitedCommand, TimedCommand, TogglableCommand
Class Method Summary collapse
Instance Method Summary collapse
- #call(*args, &block) ⇒ Object
-
#initialize(*args, &block) ⇒ Command
constructor
A new instance of Command.
Constructor Details
#initialize(*args, &block) ⇒ Command
Returns a new instance of Command.
3 4 5 |
# File 'lib/gracefully/command.rb', line 3 def initialize(*args, &block) @callable, @options = Command.normalize_arguments(*args, &block) end |
Class Method Details
.normalize_arguments(*args, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/gracefully/command.rb', line 7 def self.normalize_arguments(*args, &block) if args.size == 0 [block, {}] elsif args.size == 1 [block, args.first] elsif args.size == 2 args else raise "Invalid number of arguments: #{args.size}" end end |
Instance Method Details
#call(*args, &block) ⇒ Object
19 20 21 |
# File 'lib/gracefully/command.rb', line 19 def call(*args, &block) @callable.call *args, &block end |