Class: Alchemy::MountPoint
- Inherits:
-
Object
- Object
- Alchemy::MountPoint
- Defined in:
- lib/alchemy/mount_point.rb
Overview
Utilities for Alchemy’s mount point in the host rails app.
Constant Summary collapse
- MOUNT_POINT_REGEXP =
/mount\sAlchemy::Engine\s=>\s['|"](\/\w*)['|"]/
Class Method Summary collapse
-
.get(remove_leading_slash_if_blank = true) ⇒ Object
Returns the path of Alchemy’s mount point in current rails app.
-
.path ⇒ Object
Returns the mount point path from the Rails app routes.
Class Method Details
.get(remove_leading_slash_if_blank = true) ⇒ Object
Returns the path of Alchemy’s mount point in current rails app.
17 18 19 20 21 22 23 |
# File 'lib/alchemy/mount_point.rb', line 17 def get(remove_leading_slash_if_blank = true) if path == "/" && remove_leading_slash_if_blank path.gsub(/\A\/\z/, '') else path end end |
.path ⇒ Object
Returns the mount point path from the Rails app routes.
27 28 29 30 31 32 33 34 |
# File 'lib/alchemy/mount_point.rb', line 27 def path match = File.read(routes_file_path).match(MOUNT_POINT_REGEXP) if match.nil? raise NotMountedError else match[1] end end |