Class: HotCocoaApplication
- Includes:
- HotCocoa
- Defined in:
- lib/hotcocoa/mvc.rb
Constant Summary
Constants included from HotCocoa
HotCocoa::Behaviours, HotCocoa::VERSION
Class Attribute Summary collapse
-
.instance ⇒ HotCocoaApplication
The singleton instance of the application.
Instance Attribute Summary collapse
Instance Method Summary collapse
- #controller(controller_name) ⇒ Object
-
#initialize(application_file) ⇒ HotCocoaApplication
constructor
A new instance of HotCocoaApplication.
- #start ⇒ Object
Methods included from HotCocoa
Constructor Details
#initialize(application_file) ⇒ HotCocoaApplication
Returns 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
.instance ⇒ HotCocoaApplication
The singleton instance of the application.
20 21 22 |
# File 'lib/hotcocoa/mvc.rb', line 20 def instance @instance end |
Instance Attribute Details
#application_controller ⇒ Object
Returns [].
10 11 12 |
# File 'lib/hotcocoa/mvc.rb', line 10 def application_controller @application_controller end |
#controllers ⇒ Object
Returns [].
13 14 15 |
# File 'lib/hotcocoa/mvc.rb', line 13 def controllers @controllers end |
#shared_application ⇒ NSApplication
7 8 9 |
# File 'lib/hotcocoa/mvc.rb', line 7 def shared_application @shared_application end |
Instance Method Details
#controller(controller_name) ⇒ Object
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 |
#start ⇒ Object
36 37 38 |
# File 'lib/hotcocoa/mvc.rb', line 36 def start @shared_application.run end |