Module: Vedeu::Interfaces Private
- Extended by:
- Interfaces
- Includes:
- Common, Repository
- Included in:
- Interfaces
- Defined in:
- lib/vedeu/repositories/interfaces.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 interfaces.
Class Method Summary collapse
-
.add(attributes) ⇒ Hash|FalseClass
private
Stores the interface attributes defined by the API.
-
.build(name) ⇒ Interface
private
Create an instance of Interface from the stored attributes.
- .in_memory ⇒ Hash private private
- .not_found(name) ⇒ InterfaceNotFound private private
- .register_event(attributes) ⇒ Boolean private private
-
.reset ⇒ Hash
private
Reset the interfaces repository; removing all registered interfaces.
Instance Method Summary collapse
-
#add(attributes) ⇒ Hash|FalseClass
private
Stores the interface attributes defined by the API.
-
#build(name) ⇒ Interface
private
Create an instance of Interface from the stored attributes.
- #in_memory ⇒ Hash private private
- #not_found(name) ⇒ InterfaceNotFound private private
- #register_event(attributes) ⇒ Boolean private private
-
#reset ⇒ Hash
private
Reset the interfaces repository; removing all registered interfaces.
Methods included from Repository
#all, #find, #missing_required, #registered, #registered?, #storage, #validate_attributes!
Methods included from Common
Class Method Details
.add(attributes) ⇒ Hash|FalseClass
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 interface attributes defined by the API.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vedeu/repositories/interfaces.rb', line 16 def add(attributes) validate_attributes!(attributes) Vedeu.log("Registering interface: '#{attributes[:name]}'") storage.store(attributes[:name], attributes) register_event(attributes) true end |
.build(name) ⇒ Interface
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.
Create an instance of Interface from the stored attributes.
32 33 34 |
# File 'lib/vedeu/repositories/interfaces.rb', line 32 def build(name) Interface.new(find(name)) 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.
60 61 62 |
# File 'lib/vedeu/repositories/interfaces.rb', line 60 def in_memory {} end |
.not_found(name) ⇒ InterfaceNotFound (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.
68 69 70 71 |
# File 'lib/vedeu/repositories/interfaces.rb', line 68 def not_found(name) fail InterfaceNotFound, "Interface was not found with this name: #{name.to_s}." end |
.register_event(attributes) ⇒ Boolean (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.
51 52 53 54 55 56 |
# File 'lib/vedeu/repositories/interfaces.rb', line 51 def register_event(attributes) name = attributes[:name] delay = attributes[:delay] || 0.0 Vedeu::Refresh.register_event(:by_name, name, delay) end |
.reset ⇒ Hash
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.
Reset the interfaces repository; removing all registered interfaces. This will delete the interfaces themselves, and the client application will need to either redefine interfaces before using them, or restart.
41 42 43 |
# File 'lib/vedeu/repositories/interfaces.rb', line 41 def reset @_storage = in_memory end |
Instance Method Details
#add(attributes) ⇒ Hash|FalseClass
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 interface attributes defined by the API.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vedeu/repositories/interfaces.rb', line 16 def add(attributes) validate_attributes!(attributes) Vedeu.log("Registering interface: '#{attributes[:name]}'") storage.store(attributes[:name], attributes) register_event(attributes) true end |
#build(name) ⇒ Interface
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.
Create an instance of Interface from the stored attributes.
32 33 34 |
# File 'lib/vedeu/repositories/interfaces.rb', line 32 def build(name) Interface.new(find(name)) 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.
60 61 62 |
# File 'lib/vedeu/repositories/interfaces.rb', line 60 def in_memory {} end |
#not_found(name) ⇒ InterfaceNotFound (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.
68 69 70 71 |
# File 'lib/vedeu/repositories/interfaces.rb', line 68 def not_found(name) fail InterfaceNotFound, "Interface was not found with this name: #{name.to_s}." end |
#register_event(attributes) ⇒ Boolean (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.
51 52 53 54 55 56 |
# File 'lib/vedeu/repositories/interfaces.rb', line 51 def register_event(attributes) name = attributes[:name] delay = attributes[:delay] || 0.0 Vedeu::Refresh.register_event(:by_name, name, delay) end |
#reset ⇒ Hash
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.
Reset the interfaces repository; removing all registered interfaces. This will delete the interfaces themselves, and the client application will need to either redefine interfaces before using them, or restart.
41 42 43 |
# File 'lib/vedeu/repositories/interfaces.rb', line 41 def reset @_storage = in_memory end |