Sha256: c72472a8d0ab63cb3f4bee2375beb47a78e88689c7d79d2782e674dc161a17b2

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require 'rubygems'
require 'bundler/setup'

require 'fileutils'

module RubyApp
  require 'ruby_app/configuration'
  require 'ruby_app/log'
  require 'ruby_app/mixins'
  require 'ruby_app/version'

  class Application
    extend RubyApp::Mixins::ConfigurationMixin
    extend RubyApp::Mixins::DelegateMixin

    attr_reader :options, :environment

    def initialize
      @environment = {}
    end

    def self.get
      @@_application ||= nil
    end

    def self.exists?
      return @@_application
    end

    def self.create!
      @@_application = ( Kernel.eval(RubyApp::Application.configuration._class) ).new
    end

    def self.destroy!
      @@_application = nil
    end

    def self.create_context!(configuration_paths = [File.join(RubyApp::ROOT, %w[configuration.yml])])
      unless RubyApp::Application.exists?
        RubyApp::Configuration.load!(configuration_paths)
        RubyApp::Log.open!
        RubyApp::Application.create!
        begin
          yield
        ensure
          RubyApp::Application.destroy!
          RubyApp::Log.close!
          RubyApp::Configuration.unload!
        end
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
RubyApp-0.5.41 lib/ruby_app/application.rb