Module: Vedeu::Menus Private
- Extended by:
- Menus
- Includes:
- Common, Repository
- Included in:
- Menus
- Defined in:
- lib/vedeu/repositories/menus.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Repository for storing and retrieving defined menus.
Class Method Summary collapse
-
.add(attributes) ⇒ Hash|MissingRequired
private
Stores the menu attributes defined by the API.
-
.in_memory ⇒ Hash
private
private
Returns an empty collection ready for the storing of menus by name with associated menu instance.
- .not_found(name) ⇒ MenuNotFound private private
-
.remove(name) ⇒ Boolean
private
Removes the menu from the repository and associated events.
-
.use(name) ⇒ Vedeu::Menu
private
Access a menu by name.
Instance Method Summary collapse
-
#add(attributes) ⇒ Hash|MissingRequired
private
Stores the menu attributes defined by the API.
-
#in_memory ⇒ Hash
private
private
Returns an empty collection ready for the storing of menus by name with associated menu instance.
- #not_found(name) ⇒ MenuNotFound private private
-
#remove(name) ⇒ Boolean
private
Removes the menu from the repository and associated events.
-
#use(name) ⇒ Vedeu::Menu
private
Access a menu by name.
Methods included from Repository
#all, #find, #missing_required, #registered, #registered?, #reset, #storage, #validate_attributes!
Methods included from Common
Class Method Details
.add(attributes) ⇒ Hash|MissingRequired
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Stores the menu attributes defined by the API.
29 30 31 32 33 34 35 36 37 |
# File 'lib/vedeu/repositories/menus.rb', line 29 def add(attributes) validate_attributes!(attributes) Vedeu.log("Registering menu: '#{attributes[:name]}'") attributes.merge!({ items: Vedeu::Menu.new(attributes[:items]) }) storage.store(attributes[:name], attributes) end |
.in_memory ⇒ Hash (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns an empty collection ready for the storing of menus by name with associated menu instance.
66 67 68 |
# File 'lib/vedeu/repositories/menus.rb', line 66 def in_memory {} end |
.not_found(name) ⇒ MenuNotFound (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
74 75 76 |
# File 'lib/vedeu/repositories/menus.rb', line 74 def not_found(name) fail MenuNotFound, "Menu was not found with this name: #{name.to_s}." end |
.remove(name) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Removes the menu from the repository and associated events.
43 44 45 46 47 48 49 |
# File 'lib/vedeu/repositories/menus.rb', line 43 def remove(name) return false unless registered?(name) storage.delete(name) { false } true end |
.use(name) ⇒ Vedeu::Menu
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Access a menu by name.
55 56 57 |
# File 'lib/vedeu/repositories/menus.rb', line 55 def use(name) find(name).fetch(:items) end |
Instance Method Details
#add(attributes) ⇒ Hash|MissingRequired
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Stores the menu attributes defined by the API.
29 30 31 32 33 34 35 36 37 |
# File 'lib/vedeu/repositories/menus.rb', line 29 def add(attributes) validate_attributes!(attributes) Vedeu.log("Registering menu: '#{attributes[:name]}'") attributes.merge!({ items: Vedeu::Menu.new(attributes[:items]) }) storage.store(attributes[:name], attributes) end |
#in_memory ⇒ Hash (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns an empty collection ready for the storing of menus by name with associated menu instance.
66 67 68 |
# File 'lib/vedeu/repositories/menus.rb', line 66 def in_memory {} end |
#not_found(name) ⇒ MenuNotFound (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
74 75 76 |
# File 'lib/vedeu/repositories/menus.rb', line 74 def not_found(name) fail MenuNotFound, "Menu was not found with this name: #{name.to_s}." end |
#remove(name) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Removes the menu from the repository and associated events.
43 44 45 46 47 48 49 |
# File 'lib/vedeu/repositories/menus.rb', line 43 def remove(name) return false unless registered?(name) storage.delete(name) { false } true end |
#use(name) ⇒ Vedeu::Menu
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Access a menu by name.
55 56 57 |
# File 'lib/vedeu/repositories/menus.rb', line 55 def use(name) find(name).fetch(:items) end |