Class: Rambo::ApplicationContext

Inherits:
Object
  • Object
show all
Defined in:
lib/rambo/application_context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(application_name = nil) ⇒ ApplicationContext

Returns a new instance of ApplicationContext.



5
6
7
8
9
10
11
# File 'lib/rambo/application_context.rb', line 5

def initialize(application_name = nil)
  @application_name = application_name
  puts "Initializing application: #{application_name || 'default'}"
  @prefix = "#{self.application_name}/" if self.application_name
  @prefix ||= ''
  load_classes
end

Instance Attribute Details

#application_nameObject

Returns the value of attribute application_name.



3
4
5
# File 'lib/rambo/application_context.rb', line 3

def application_name
  @application_name
end

Instance Method Details

#load_classesObject



13
14
15
16
17
18
# File 'lib/rambo/application_context.rb', line 13

def load_classes
  Dir["#{@prefix}controller/*.rb"].each { |x| funkyload x; }
  Dir["#{@prefix}model/*.rb"].each { |x| funkyload x }
  Dir["#{@prefix}lib/*.rb"].each { |x| funkyload x }
  Dir["#{@prefix}*.rb"].each { |x| funkyload x unless x == 'Rakefile.rb' }
end

#reloadObject



20
21
22
# File 'lib/rambo/application_context.rb', line 20

def reload
  load_classes
end

#view_pathObject



24
25
26
# File 'lib/rambo/application_context.rb', line 24

def view_path
  "./#{@prefix}view"
end