Class: HotCocoaApplication
- Inherits:
-
Object
- Object
- HotCocoaApplication
- Includes:
- HotCocoa
- Defined in:
- lib/hotcocoa/mvc.rb
Constant Summary
Constant Summary
Constants included from HotCocoa
Class Attribute Summary (collapse)
-
+ (HotCocoaApplication) instance
The singleton instance of the application.
Instance Attribute Summary (collapse)
-
- (Object) application_controller
[].
-
- (Object) controllers
[].
- - (NSApplication) shared_application
Instance Method Summary (collapse)
- - (Object) controller(controller_name)
-
- (HotCocoaApplication) initialize(application_file)
constructor
A new instance of HotCocoaApplication.
- - (Object) start
Methods included from HotCocoa
Constructor Details
- (HotCocoaApplication) initialize(application_file)
A new instance of HotCocoaApplication
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/hotcocoa/mvc.rb', line 23 def initialize application_file HotCocoaApplication.instance = self @controllers = {} load_controllers_and_views(directory_of(application_file)) @shared_application = application(ApplicationView.[:application]) @shared_application. @application_controller = controller(:application_controller) shared_application.delegate_to(application_controller) end |
Class Attribute Details
+ (HotCocoaApplication) instance
The singleton instance of the application.
20 21 22 |
# File 'lib/hotcocoa/mvc.rb', line 20 def instance @instance end |
Instance Attribute Details
- (Object) application_controller
[]
10 11 12 |
# File 'lib/hotcocoa/mvc.rb', line 10 def application_controller @application_controller end |
- (Object) controllers
[]
13 14 15 |
# File 'lib/hotcocoa/mvc.rb', line 13 def controllers @controllers end |
- (NSApplication) shared_application
7 8 9 |
# File 'lib/hotcocoa/mvc.rb', line 7 def shared_application @shared_application end |
Instance Method Details
- (Object) controller(controller_name)
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/hotcocoa/mvc.rb', line 40 def controller controller_name controller_name_string = controller_name.to_s controller_class = if Object.const_get(controller_name_string !~ /_/ && controller_name_string =~ /[A-Z]+.*/) controller_name_string else controller_name_string.split('_').map { |e| e.capitalize }.join end @controllers[controller_name] || create_controller_instance(controller_name, controller_class) end |
- (Object) start
36 37 38 |
# File 'lib/hotcocoa/mvc.rb', line 36 def start @shared_application.run end |