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

Instance Method Summary collapse

Methods included from Repository

#all, #find, #missing_required, #registered, #registered?, #reset, #storage, #validate_attributes!

Methods included from Common

#defined_value?

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.

Parameters:

  • attributes (Hash)

Returns:



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_memoryHash (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.

Returns:

  • (Hash)


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.

Parameters:

  • name (String)

Returns:

Raises:

  • (MenuNotFound)

    When the entity cannot be found with this name.



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.

Parameters:

  • name (String)

Returns:

  • (Boolean)


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.

Parameters:

  • name (String)

Returns:



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.

Parameters:

  • attributes (Hash)

Returns:



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_memoryHash (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.

Returns:

  • (Hash)


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.

Parameters:

  • name (String)

Returns:

Raises:

  • (MenuNotFound)

    When the entity cannot be found with this name.



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.

Parameters:

  • name (String)

Returns:

  • (Boolean)


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.

Parameters:

  • name (String)

Returns:



55
56
57
# File 'lib/vedeu/repositories/menus.rb', line 55

def use(name)
  find(name).fetch(:items)
end