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
-
#visible ⇒ Boolean
(also: #visible?)
Whether the toggleable is visible.
Class Method Summary collapse
-
.included(klass) ⇒ void
When this module is included in a class, provide ClassMethods as class methods for the class.
Instance Method Summary collapse
-
#hide ⇒ FalseClass
Set the visible state to false and store the model.
-
#show ⇒ TrueClass
Set the visible state to true and store the model.
-
#toggle ⇒ FalseClass|TrueClass
Toggle the visible state and store the model.
Instance Attribute Details
#visible ⇒ Boolean Also known as: visible?
Returns 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.
104 105 106 |
# File 'lib/vedeu/models/toggleable.rb', line 104 def self.included(klass) klass.send(:extend, ClassMethods) end |
Instance Method Details
#hide ⇒ FalseClass
Set the visible state to false and store the model.
19 20 21 22 23 |
# File 'lib/vedeu/models/toggleable.rb', line 19 def hide @visible = false store end |
#show ⇒ TrueClass
Set the visible state to true and store the model.
28 29 30 31 32 |
# File 'lib/vedeu/models/toggleable.rb', line 28 def show @visible = true store end |
#toggle ⇒ FalseClass|TrueClass
Toggle the visible state and store the model. When the model is hidden, then it is shown, and vice versa.
38 39 40 41 42 |
# File 'lib/vedeu/models/toggleable.rb', line 38 def toggle return hide if visible? show end |