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: ClassMethods

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.



13
14
15
# File 'lib/vedeu/models/toggleable.rb', line 13

def visible
  @visible
end

Class Method Details

.included(klass) ⇒ void

This method returns an undefined value.

When this module is included in a class, provide ClassMethods as class methods for the class.

Parameters:

  • klass (Class)


104
105
106
# File 'lib/vedeu/models/toggleable.rb', line 104

def self.included(klass)
  klass.send(:extend, ClassMethods)
end

Instance Method Details

#hideFalseClass

Set the visible state to false and store the model.

Returns:

  • (FalseClass)


19
20
21
22
23
# File 'lib/vedeu/models/toggleable.rb', line 19

def hide
  @visible = false

  store
end

#showTrueClass

Set the visible state to true and store the model.

Returns:

  • (TrueClass)


28
29
30
31
32
# File 'lib/vedeu/models/toggleable.rb', line 28

def show
  @visible = true

  store
end

#toggleFalseClass|TrueClass

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

Returns:

  • (FalseClass|TrueClass)


38
39
40
41
42
# File 'lib/vedeu/models/toggleable.rb', line 38

def toggle
  return hide if visible?

  show
end