Class: WelltreatStoreFramework::StoreApp
- Inherits:
-
Object
- Object
- WelltreatStoreFramework::StoreApp
- Includes:
- HamlRenderer
- Defined in:
- lib/welltreat_store_framework/store_app.rb
Defined Under Namespace
Classes: ActionNotFound, AppStack, ControllerNotFound, ExecutionError, TemplateNotFound, TemplateRenderingError
Instance Attribute Summary collapse
-
#assets_path ⇒ Object
Declare attribute accessors.
-
#config_path ⇒ Object
Declare attribute accessors.
-
#controllers_path ⇒ Object
Declare attribute accessors.
-
#models_path ⇒ Object
Declare attribute accessors.
-
#name ⇒ Object
Declare attribute accessors.
-
#partition_object ⇒ Object
Declare attribute accessors.
-
#path ⇒ Object
Declare attribute accessors.
-
#routes_path ⇒ Object
Declare attribute accessors.
-
#started ⇒ Object
Declare attribute accessors.
-
#views ⇒ Object
Declare attribute accessors.
-
#views_path ⇒ Object
Declare attribute accessors.
Instance Method Summary collapse
- #base ⇒ Object
-
#call(env) ⇒ Object
Make it rack compatible.
- #controllers ⇒ Object
-
#dispatch(path, request, response, options) ⇒ Object
Handle request for the specified path and request Return status and html content string.
-
#initialize(attrs = { }) ⇒ StoreApp
constructor
Default constructor with attribute hash, if attribute hash is passed it will set value through setter accessors.
- #models ⇒ Object
-
#restart ⇒ Object
Stop and start application.
-
#start ⇒ Object
Start application Return true if successful otherwise false.
-
#stop ⇒ Object
Dispose and stop application Return true if successful otherwise false.
Methods included from HamlRenderer
#_full_layout_path, #_full_partial_template_path, #_full_template_path, #_haml_engines, #_singleton_haml_instance, #render!
Constructor Details
#initialize(attrs = { }) ⇒ StoreApp
Default constructor with attribute hash, if attribute hash is passed it will set value through setter accessors
55 56 57 58 59 60 61 |
# File 'lib/welltreat_store_framework/store_app.rb', line 55 def initialize(attrs = { }) if attrs.present? attrs.each do |k, v| self.send(:"#{k}=", v) end end end |
Instance Attribute Details
#assets_path ⇒ Object
Declare attribute accessors
49 50 51 |
# File 'lib/welltreat_store_framework/store_app.rb', line 49 def assets_path @assets_path end |
#config_path ⇒ Object
Declare attribute accessors
49 50 51 |
# File 'lib/welltreat_store_framework/store_app.rb', line 49 def config_path @config_path end |
#controllers_path ⇒ Object
Declare attribute accessors
49 50 51 |
# File 'lib/welltreat_store_framework/store_app.rb', line 49 def controllers_path @controllers_path end |
#models_path ⇒ Object
Declare attribute accessors
49 50 51 |
# File 'lib/welltreat_store_framework/store_app.rb', line 49 def models_path @models_path end |
#name ⇒ Object
Declare attribute accessors
49 50 51 |
# File 'lib/welltreat_store_framework/store_app.rb', line 49 def name @name end |
#partition_object ⇒ Object
Declare attribute accessors
49 50 51 |
# File 'lib/welltreat_store_framework/store_app.rb', line 49 def partition_object @partition_object end |
#path ⇒ Object
Declare attribute accessors
49 50 51 |
# File 'lib/welltreat_store_framework/store_app.rb', line 49 def path @path end |
#routes_path ⇒ Object
Declare attribute accessors
49 50 51 |
# File 'lib/welltreat_store_framework/store_app.rb', line 49 def routes_path @routes_path end |
#started ⇒ Object
Declare attribute accessors
49 50 51 |
# File 'lib/welltreat_store_framework/store_app.rb', line 49 def started @started end |
#views ⇒ Object
Declare attribute accessors
49 50 51 |
# File 'lib/welltreat_store_framework/store_app.rb', line 49 def views @views end |
#views_path ⇒ Object
Declare attribute accessors
49 50 51 |
# File 'lib/welltreat_store_framework/store_app.rb', line 49 def views_path @views_path end |
Instance Method Details
#base ⇒ Object
93 94 95 |
# File 'lib/welltreat_store_framework/store_app.rb', line 93 def base; _base_module end |
#call(env) ⇒ Object
Make it rack compatible
134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/welltreat_store_framework/store_app.rb', line 134 def call(env) request = WelltreatStoreFramework::Controller::Request.initialize_from_env(env) response = WelltreatStoreFramework::Controller::Response.new = { session: env['rack.session'] } dispatch request.path, request, response, render! request, response, [response.status, response.headers, [response.content]] end |
#controllers ⇒ Object
101 102 103 |
# File 'lib/welltreat_store_framework/store_app.rb', line 101 def controllers base::Controllers end |
#dispatch(path, request, response, options) ⇒ Object
Handle request for the specified path and request Return status and html content string
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/welltreat_store_framework/store_app.rb', line 108 def dispatch(path, request, response, ) if WelltreatStoreFramework::Core.configuration.auto_reload restart end begin case path when '/' _execute_action(:Home, :index, request, response, ) else _controller_name, _action, _id = self.send(:_extract_path, path) request.send(:set_param, :id, _id) _execute_action(_controller_name, _action, request, response, ) end # Handle 404 rescue WelltreatStoreFramework::StoreApp::ControllerNotFound _execute_action(:Home, :not_found, request, response, ) rescue WelltreatStoreFramework::StoreApp::ActionNotFound _execute_action(:Home, :not_found, request, response, ) end end |
#models ⇒ Object
97 98 99 |
# File 'lib/welltreat_store_framework/store_app.rb', line 97 def models base::Models end |
#restart ⇒ Object
Stop and start application
83 84 85 86 87 88 89 90 91 |
# File 'lib/welltreat_store_framework/store_app.rb', line 83 def restart if self.started self.stop self.start true else false end end |
#start ⇒ Object
Start application Return true if successful otherwise false
65 66 67 68 |
# File 'lib/welltreat_store_framework/store_app.rb', line 65 def start _bootstrap! self.started = true end |
#stop ⇒ Object
Dispose and stop application Return true if successful otherwise false
72 73 74 75 76 77 78 79 80 |
# File 'lib/welltreat_store_framework/store_app.rb', line 72 def stop if self.started _dispose! self.started = false true else false end end |