module DeferrableGratification
Deferrable Gratification ({DG}) makes evented code less error-prone and easier to compose, and thus easier to create higher-level abstractions around. It also enhances the API offered by Ruby Deferrables to make them more pleasant to work with.
@see Fluent
@see Bothback
@see Combinators
Public Class Methods
Bestow DG
goodness upon an existing module or class.
N.B. calling this on a module won’t enhance any classes that have already included that module.
# File lib/deferrable_gratification.rb, line 39 def self.enhance!(module_or_class) module_or_class.send :include, Combinators module_or_class.send :include, Fluent module_or_class.send :include, Bothback end
Enhance EventMachine::Deferrable itself so that any class including it gets DG
goodness. This should mean that all Deferrables in the current process will get enhanced.
N.B. this will not enhance any classes that have already included Deferrable before this method was called, so you should call this before loading any other Deferrable libraries, and before defining any of your own Deferrable classes. (If that isn’t possible, you can always call {enhance!} on them after definition.)
# File lib/deferrable_gratification.rb, line 54 def self.enhance_all_deferrables! require 'eventmachine' require 'em/deferrable' enhance! EventMachine::Deferrable # Also have to do that to EM::DefaultDeferrable because it included # Deferrable before we enhanced it. enhance! EventMachine::DefaultDeferrable end