Sha256: dc4747215998b5d1203c70d849c6c9e8616975470ee392edcd5a51d720af888c

Contents?: true

Size: 823 Bytes

Versions: 3

Compression:

Stored size: 823 Bytes

Contents

module Delayed
  module Workless 
    module Scaler
    
      def self.included(base)
        
        base.send :extend, ClassMethods
        base.class_eval do
          after_destroy "self.class.scaler.down"
          before_create "self.class.scaler.up"
          after_update "self.class.scaler.down", :unless => Proc.new {|r| r.failed_at.nil? }
        end
        
      end
      
      module ClassMethods
        def scaler
          @scaler ||= if ENV.include?("HEROKU_UPID")
            require File.dirname(__FILE__) + "/scalers/heroku"
            Scaler::Heroku.new
          else
            require File.dirname(__FILE__) + "/scalers/local"
            Scaler::Local.new
          end
        end

        def scaler=(scaler)
          @scaler = scaler
        end
      end
      
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workless-0.0.3 lib/workless/scaler.rb
workless-0.0.2 lib/workless/scaler.rb
workless-0.0.1 lib/workless/scaler.rb