Class: RubyApp::Application

Inherits:
Object show all
Extended by:
Mixins::ConfigurationMixin, Mixins::DelegateMixin
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::ConfigurationMixin

configuration

Methods included from Mixins::DelegateMixin

exists?, method_missing

Constructor Details

#initializeApplication

Returns a new instance of Application.



18
19
20
21
22
23
24
25
26
# File 'lib/ruby_app/application.rb', line 18

def initialize

  @environment = {}

  RubyApp::Log.info("LOG       RubyApp::Application.root                    = #{RubyApp::Application.root.inspect}")
  RubyApp::Log.info("LOG       RubyApp::Response.configuration.cache.read?  = #{RubyApp::Response.configuration.cache.read?}")
  RubyApp::Log.info("LOG       RubyApp::Response.configuration.cache.write? = #{RubyApp::Response.configuration.cache.write?}")

end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



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

def environment
  @environment
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Class Method Details

.create!Object



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

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

.create_context!(configuration_paths = File.join(RubyApp::ROOT, %w[configuration.yml])) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/ruby_app/application.rb', line 56

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

.destroy!Object



52
53
54
# File 'lib/ruby_app/application.rb', line 52

def self.destroy!
  @@_application = nil
end

.exists?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/ruby_app/application.rb', line 44

def self.exists?
  return @@_application ||= nil
end

.getObject



40
41
42
# File 'lib/ruby_app/application.rb', line 40

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

.rootObject



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

def self.root
  @@_root ||= '/'
end

.root=(value) ⇒ Object



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

def self.root=(value)
  @@_root = value
end

.root_or_nilObject



36
37
38
# File 'lib/ruby_app/application.rb', line 36

def self.root_or_nil
  return self.root.nil_if('/')
end