Module: Locomotive::Plugin::RackAppHelpers
- Included in:
- Locomotive::Plugin
- Defined in:
- lib/locomotive/plugin/rack_app_helpers.rb
Overview
This module adds helpers for handling the Rack app supplied by the rack_app
method.
Defined Under Namespace
Modules: ClassMethods, HelperMethods
Instance Method Summary collapse
-
#mounted_rack_app ⇒ Object
Delegates to ClassMethods#mounted_rack_app.
-
#mountpoint ⇒ Object
The mountpoint of the Rack app.
-
#mountpoint=(mountpoint) ⇒ Object
Set the mountpoint of the Rack app.
-
#rack_app_full_path(path) ⇒ Object
Generate the full absolute path within the plugin’s rack app for the given path based on the mountpoint.
-
#rack_app_full_url(path) ⇒ Object
Generate the full URL for the given path based on the mountpoint of this plugin’s rack app.
Instance Method Details
#mounted_rack_app ⇒ Object
Delegates to ClassMethods#mounted_rack_app.
92 93 94 |
# File 'lib/locomotive/plugin/rack_app_helpers.rb', line 92 def mounted_rack_app self.class.mounted_rack_app end |
#mountpoint ⇒ Object
The mountpoint of the Rack app.
52 53 54 |
# File 'lib/locomotive/plugin/rack_app_helpers.rb', line 52 def mountpoint @mountpoint ||= '/' end |
#mountpoint=(mountpoint) ⇒ Object
Set the mountpoint of the Rack app.
59 60 61 |
# File 'lib/locomotive/plugin/rack_app_helpers.rb', line 59 def mountpoint=(mountpoint) @mountpoint = mountpoint end |
#rack_app_full_path(path) ⇒ Object
Generate the full absolute path within the plugin’s rack app for the given path based on the mountpoint.
69 70 71 72 73 74 |
# File 'lib/locomotive/plugin/rack_app_helpers.rb', line 69 def rack_app_full_path(path) [ base_uri_object.path.sub(%r{/+$}, ''), path.sub(%r{^/+}, '') ].join('/') end |
#rack_app_full_url(path) ⇒ Object
Generate the full URL for the given path based on the mountpoint of this plugin’s rack app.
82 83 84 85 86 87 |
# File 'lib/locomotive/plugin/rack_app_helpers.rb', line 82 def rack_app_full_url(path) [ base_uri_object.to_s.sub(%r{/+$}, ''), path.sub(%r{^/+}, '') ].join('/') end |