Class: Menu
Constant Summary
collapse
- CACHE_KEY =
'forest_menus'
Class Method Summary
collapse
Instance Method Summary
collapse
cache_key, cache_key_name, csv_columns, #expire_cache_key, expire_cache_key, statusable?, #statusable?, to_csv_template, #to_friendly_param, #to_label, #to_select2_response, #to_select2_selection, versionable, #versionable
Class Method Details
.expire_cache! ⇒ Object
14
15
16
|
# File 'app/models/menu.rb', line 14
def self.expire_cache!
Rails.cache.delete CACHE_KEY
end
|
.for(slug) ⇒ Object
10
11
12
|
# File 'app/models/menu.rb', line 10
def self.for(slug)
self..select { || .slug == slug.to_s }.first
end
|
.resource_description ⇒ Object
18
19
20
|
# File 'app/models/menu.rb', line 18
def self.resource_description
"Menus are where you edit the navigation structure of your website. Menu items are composed of custom links or associations with pages."
end
|
Instance Method Details
#nokogiri ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'app/models/menu.rb', line 26
def nokogiri
@nokogiri ||= begin
fragment = Nokogiri::HTML.fragment('<ul></ul>')
structure_as_json.each do ||
create_nokogiri_children(, fragment.at_css('ul'))
end
fragment
end
end
|
#render ⇒ Object
36
37
38
|
# File 'app/models/menu.rb', line 36
def render
nokogiri.to_html.html_safe
end
|
#structure_as_json ⇒ Object
22
23
24
|
# File 'app/models/menu.rb', line 22
def structure_as_json
JSON.parse(structure.presence || '[]')
end
|