Class: Grumlin::Shortcut
- Inherits:
-
Object
- Object
- Grumlin::Shortcut
- Extended by:
- Forwardable
- Defined in:
- lib/grumlin/shortcut.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#apply(object, *args, **params) ⇒ Object
TODO: to_s, inspect, preview.
-
#initialize(name, lazy: true, &block) ⇒ Shortcut
constructor
A new instance of Shortcut.
- #lazy? ⇒ Boolean
Constructor Details
#initialize(name, lazy: true, &block) ⇒ Shortcut
Returns a new instance of Shortcut.
11 12 13 14 15 |
# File 'lib/grumlin/shortcut.rb', line 11 def initialize(name, lazy: true, &block) @name = name @lazy = lazy @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
6 7 8 |
# File 'lib/grumlin/shortcut.rb', line 6 def block @block end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/grumlin/shortcut.rb', line 6 def name @name end |
Instance Method Details
#==(other) ⇒ Object
17 18 19 |
# File 'lib/grumlin/shortcut.rb', line 17 def ==(other) @name == other.name && @block == other.block end |
#apply(object, *args, **params) ⇒ Object
TODO: to_s, inspect, preview
27 28 29 |
# File 'lib/grumlin/shortcut.rb', line 27 def apply(object, *args, **params) object.instance_exec(*args, **params, &@block) end |
#lazy? ⇒ Boolean
21 22 23 |
# File 'lib/grumlin/shortcut.rb', line 21 def lazy? @lazy end |