Class: RubyApp::Application

Inherits:
Object
  • Object
show all
Extended by:
Mixins::DelegateMixin
Includes:
Mixins::ConfigureMixin
Defined in:
lib/ruby_app/application.rb

Direct Known Subclasses

_APPLICATION_UPCODE_::Application

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixins::DelegateMixin

method_missing

Methods included from Mixins::ConfigureMixin

#configure

Constructor Details

#initialize(options) ⇒ Application

Returns a new instance of Application.



16
17
18
19
# File 'lib/ruby_app/application.rb', line 16

def initialize(options)
  @options = options
  @environment = {}
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



14
15
16
# File 'lib/ruby_app/application.rb', line 14

def environment
  @environment
end

#optionsObject (readonly)

Returns the value of attribute options.



14
15
16
# File 'lib/ruby_app/application.rb', line 14

def options
  @options
end

Class Method Details

.create!(options = {}) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ruby_app/application.rb', line 35

def self.create!(options = {})
  _options = { :application_class => RubyApp::Application,
               :session_class => RubyApp::Session,
               :log_path => File.join(RubyApp::ROOT, %w[log application.log]),
               :configuration_paths => [],
               :default_language => :en,
               :translations_paths => [] }.merge(options)
  _options.configuration_paths = [File.join(RubyApp::ROOT, %w[config.yml])] + ( _options.configuration_paths.is_a?(Array) ? _options.configuration_paths : [_options.configuration_paths] )
  _options.translations_paths = [File.join(RubyApp::ROOT, %w[translations])] + ( _options.translations_paths.is_a?(Array) ? _options.translations_paths : [_options.translations_paths] )
  @@_application = _options.application_class.new(_options)
  @@_application.start!
end

.destroy!Object



48
49
50
51
# File 'lib/ruby_app/application.rb', line 48

def self.destroy!
  @@_application.stop!
  @@_application = nil
end

.getObject



31
32
33
# File 'lib/ruby_app/application.rb', line 31

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

Instance Method Details

#start!Object



21
22
23
24
# File 'lib/ruby_app/application.rb', line 21

def start!
  RubyApp::Log.open!
  RubyApp::Configuration.load!
end

#stop!Object



26
27
28
29
# File 'lib/ruby_app/application.rb', line 26

def stop!
  RubyApp::Configuration.unload!
  RubyApp::Log.close!
end