Class: Alchemy::Node

Inherits:
BaseRecord
  • Object
show all
Defined in:
app/models/alchemy/node.rb

Constant Summary collapse

VALID_URL_REGEX =
/\A(\/|\D[a-z+\d.-]+:)/

Constants included from SearchableResource

SearchableResource::SEARCHABLE_COLUMN_TYPES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SearchableResource

#ransackable_associations, #ransackable_attributes, #ransortable_attributes

Class Method Details

.available_menu_namesObject



45
46
47
# File 'app/models/alchemy/node.rb', line 45

def available_menu_names
  read_definitions_file
end

.language_root_nodesObject

Returns all root nodes for current language



39
40
41
42
43
# File 'app/models/alchemy/node.rb', line 39

def language_root_nodes
  raise "No language found" if Language.current.nil?

  roots.where(language_id: Language.current.id)
end

Instance Method Details

#nameObject

Returns the name

Either the value is stored in the database or, if attached, the values comes from a page.



33
34
35
# File 'app/models/alchemy/node.rb', line 33

def name
  read_attribute(:name).presence || page&.name
end

#to_partial_pathObject



76
77
78
# File 'app/models/alchemy/node.rb', line 76

def to_partial_path
  "alchemy/menus/#{menu_type}/node"
end

#urlObject

Returns the url

Either the value is stored in the database, aka. an external url. Or, if attached, the values comes from a page.



72
73
74
# File 'app/models/alchemy/node.rb', line 72

def url
  page&.url_path || read_attribute(:url).presence
end