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

Instance Method Summary collapse

Methods included from Repository

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

Methods included from Common

#defined_value?

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.

Parameters:

  • attributes (Hash)

Returns:

  • (Hash|FalseClass)


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.

Parameters:

  • name (String)

Returns:



32
33
34
# File 'lib/vedeu/repositories/interfaces.rb', line 32

def build(name)
  Interface.new(find(name))
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:

  • (Hash)


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.

Parameters:

  • name (String)

Returns:

Raises:



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.

Parameters:

  • attributes (Hash)

Returns:

  • (Boolean)

See Also:

  • Refresh.register_event


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

.resetHash

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.

Returns:

  • (Hash)


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.

Parameters:

  • attributes (Hash)

Returns:

  • (Hash|FalseClass)


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.

Parameters:

  • name (String)

Returns:



32
33
34
# File 'lib/vedeu/repositories/interfaces.rb', line 32

def build(name)
  Interface.new(find(name))
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:

  • (Hash)


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.

Parameters:

  • name (String)

Returns:

Raises:



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.

Parameters:

  • attributes (Hash)

Returns:

  • (Boolean)

See Also:

  • Refresh.register_event


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

#resetHash

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.

Returns:

  • (Hash)


41
42
43
# File 'lib/vedeu/repositories/interfaces.rb', line 41

def reset
  @_storage = in_memory
end