lib/backgrounded.rb in backgrounded-0.7.5 vs lib/backgrounded.rb in backgrounded-2.0.0.pre1
- old
+ new
@@ -1,20 +1,30 @@
require 'active_support/all'
-require File.join(File.dirname(__FILE__), 'backgrounded', 'class_methods')
require File.join(File.dirname(__FILE__), 'backgrounded', 'handler', 'inprocess_handler')
+require File.join(File.dirname(__FILE__), 'backgrounded', 'proxy')
-Object.send(:include, Backgrounded::ClassMethods)
-
module Backgrounded
+ extend ActiveSupport::Concern
+
class << self
attr_accessor :logger, :handler
- def method_name_for_backgrounded_options(method_name)
- method_basename, punctuation = method_name.to_s.sub(/([?!=])$/, ''), $1
- "#{method_basename}_backgrounded_options"
+ end
+
+ module ClassMethods
+ def backgrounded(options={})
+ Backgrounded::Proxy.new self, options
end
end
+
+ # @param options (optional) options to pass into the backgrounded handler
+ def backgrounded(options={})
+ Backgrounded::Proxy.new self, options
+ end
end
+
+# include backgrounded into any ruby object
+Object.send(:include, Backgrounded)
# default handler to the basic in process handler
Backgrounded.handler = Backgrounded::Handler::InprocessHandler.new
# configure default logger to standard out with info log level