Sha256: 4ad70ae1cec8e08f73119e374abbf30ebb212d1a24dc3aa0722fb04e54646ef7

Contents?: true

Size: 1015 Bytes

Versions: 3

Compression:

Stored size: 1015 Bytes

Contents

module Scales
  module Worker
    module Application
      module Rails
        ENV['RAILS_ENV'] ||= Scales.env
        
        class << self
        
          @@app = nil
        
          def initialize_app!
            @@app ||= load_application.initialize!
            raise "Could not load Rails Application" if @@app.nil?
            @@app
          end
          alias_method :app,                      :initialize_app!
          alias_method :initialize_environment!,  :initialize_app!
          
          def name
            "Rails #{app.class.to_s.split("::").first} (#{ENV['RAILS_ENV']})"
          end
    
          private
          
          def load_application
            before_modules = Object.constants
            require './config/application.rb'
            after_modules  = Object.constants
            delta_modules  = after_modules - before_modules
            
            Kernel.const_get(delta_modules.last)::Application
          end
    
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
scales-worker-0.0.4 lib/scales-worker/application/rails.rb
scales-worker-0.0.1.beta.2 lib/scales-worker/application/rails.rb
scales-worker-0.0.1.beta.1 lib/scales-worker/application/rails.rb