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

Constructor Details

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

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



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

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameString|Symbol (readonly, protected)



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

def name
  @name
end

Class Method Details

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



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

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

Instance Method Details

#absent?(variable) ⇒ Boolean Originally defined in module Common

Returns a boolean indicating whether a variable is nil or empty.

#by_namevoid



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

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

#demodulize(klass) ⇒ String Originally defined in module Common

Removes the module part from the expression in the string.

Examples:

demodulize('Vedeu::SomeModule::SomeClass') # => "SomeClass"

#group_from_interfaceString|Symbol (private)



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

def group_from_interface
  @_group_name ||= Vedeu.interfaces.by_name(name).group
end

#group_nameString (private)

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)

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

#present?(variable) ⇒ Boolean Originally defined in module Common

Returns a boolean indicating whether a variable has a useful value.

#snake_case(name) ⇒ String Originally defined in module Common

Converts a class name to a lowercase snake case string.

Examples:

snake_case(MyClassName) # => "my_class_name"
snake_case(NameSpaced::ClassName)
# => "name_spaced/class_name"