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.
15 16 17 18 19 20 21 |
# File 'lib/alchemy/mount_point.rb', line 15 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.
25 26 27 28 29 30 31 32 |
# File 'lib/alchemy/mount_point.rb', line 25 def path match = File.read(routes_file_path).match(MOUNT_POINT_REGEXP) if match.nil? raise NotMountedError else match[1] end end |