Class: Alchemy::Node
- Inherits:
-
BaseRecord
- Object
- ActiveRecord::Base
- BaseRecord
- Alchemy::Node
- Defined in:
- app/models/alchemy/node.rb
Constant Summary collapse
- VALID_URL_REGEX =
/\A(\/|\D[a-z\+\d\.\-]+:)/
Class Method Summary collapse
- .available_menu_names ⇒ Object
-
.language_root_nodes ⇒ Object
Returns all root nodes for current language.
Instance Method Summary collapse
-
#name ⇒ Object
Returns the name.
- #to_partial_path ⇒ Object
-
#url ⇒ Object
Returns the url.
- #view_folder_name ⇒ Object
Methods inherited from BaseRecord
Class Method Details
.available_menu_names ⇒ Object
33 34 35 |
# File 'app/models/alchemy/node.rb', line 33 def read_definitions_file end |
Instance Method Details
#name ⇒ Object
Returns the name
Either the value is stored in the database or, if attached, the values comes from a page.
21 22 23 |
# File 'app/models/alchemy/node.rb', line 21 def name read_attribute(:name).presence || page&.name end |
#to_partial_path ⇒ Object
64 65 66 |
# File 'app/models/alchemy/node.rb', line 64 def to_partial_path "#{view_folder_name}/wrapper" end |
#url ⇒ Object
Returns the url
Either the value is stored in the database, aka. an external url. Or, if attached, the values comes from a page.
60 61 62 |
# File 'app/models/alchemy/node.rb', line 60 def url page&.url_path || read_attribute(:url).presence end |
#view_folder_name ⇒ Object
68 69 70 |
# File 'app/models/alchemy/node.rb', line 68 def view_folder_name "alchemy/menus/#{name.parameterize.underscore}" end |