Module: Vedeu::Toggleable

Included in:
Cursors::Cursor, Groups::Group, Interfaces::Interface
Defined in:
lib/vedeu/models/toggleable.rb

Overview

This module provides behaviour for certain classes which can be toggled between being shown and hidden.

Currently using this are: Cursors::Cursor, Groups::Group and Interfaces::Interface.

Defined Under Namespace

Modules: SingletonMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#visibleBoolean Also known as: visible?

Returns Whether the toggleable is visible.

Returns:

  • (Boolean)

    Whether the toggleable is visible.



15
16
17
# File 'lib/vedeu/models/toggleable.rb', line 15

def visible
  @visible
end

Class Method Details

.included(klass) ⇒ Class

Provide additional behaviour to a class or module.

Parameters:

  • klass (Class)

Returns:

  • (Class)

    Returns the klass parameter.



149
150
151
# File 'lib/vedeu/models/toggleable.rb', line 149

def self.included(klass)
  klass.extend(Vedeu::Toggleable::SingletonMethods)
end

Instance Method Details

#hideBoolean

Set the visible state to false and store the model.

Returns:



21
22
23
24
25
# File 'lib/vedeu/models/toggleable.rb', line 21

def hide
  @visible = false

  store
end

#showBoolean

Set the visible state to true and store the model.

Returns:



30
31
32
33
34
# File 'lib/vedeu/models/toggleable.rb', line 30

def show
  @visible = true

  store
end

#toggleBoolean

Toggle the visible state and store the model. When the model is hidden, then it is shown, and vice versa.

Returns:



40
41
42
43
44
# File 'lib/vedeu/models/toggleable.rb', line 40

def toggle
  return hide if visible?

  show
end