Class: Vedeu::Groups::Refresh

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/vedeu/groups/refresh.rb

Overview

Refresh an interface, or collection of interfaces belonging to a group.

The interfaces will be refreshed in z-index order, meaning that interfaces with a lower z-index will be drawn first. This means overlapping interfaces will be drawn as specified.

Examples:

Vedeu.trigger(:_refresh_group_, group_name)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Common

#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?

Constructor Details

#initialize(name) ⇒ Vedeu::Groups::Refresh

Return a new instance of Vedeu::Groups::Refresh.

Parameters:

  • name (NilClass|Symbol|String)

    The name of the model or target model to act upon. May default to ‘Vedeu.focus`.



33
34
35
# File 'lib/vedeu/groups/refresh.rb', line 33

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameString|Symbol (readonly, protected)

Returns:

  • (String|Symbol)


50
51
52
# File 'lib/vedeu/groups/refresh.rb', line 50

def name
  @name
end

Class Method Details

.by_name(name) ⇒ Array|Vedeu::Error::ModelNotFound

Returns A collection of the names of interfaces refreshed, or an exception when the group was not found.

Parameters:

  • name (NilClass|Symbol|String)

    The name of the model or target model to act upon. May default to ‘Vedeu.focus`.

Returns:

  • (Array|Vedeu::Error::ModelNotFound)

    A collection of the names of interfaces refreshed, or an exception when the group was not found.



25
26
27
# File 'lib/vedeu/groups/refresh.rb', line 25

def self.by_name(name)
  new(name).by_name
end

Instance Method Details

#by_namevoid

This method returns an undefined value.



38
39
40
41
42
43
44
# File 'lib/vedeu/groups/refresh.rb', line 38

def by_name
  Vedeu.timer("Refresh Group: '#{group_name}'") do
    Vedeu.groups.by_name(group_name).by_zindex.each do |name|
      Vedeu.trigger(:_refresh_view_, name)
    end
  end
end

#group_from_interfaceString|Symbol (private)

Returns:

  • (String|Symbol)


65
66
67
# File 'lib/vedeu/groups/refresh.rb', line 65

def group_from_interface
  @_group_name ||= interface.group
end

#group_nameString (private)

Returns:

  • (String)

Raises:



56
57
58
59
60
61
62
# File 'lib/vedeu/groups/refresh.rb', line 56

def group_name
  return name if present?(name)
  return group_from_interface if present?(group_from_interface)

  raise Vedeu::Error::MissingRequired,
        'Cannot refresh group with an empty group name.'
end

#interfaceVedeu::Interfaces::Interface (private)



70
71
72
# File 'lib/vedeu/groups/refresh.rb', line 70

def interface
  Vedeu.interfaces.by_name(name)
end