Class: Grumlin::Shortcuts::Storage
- Inherits:
-
Object
- Object
- Grumlin::Shortcuts::Storage
- Extended by:
- Forwardable
- Defined in:
- lib/grumlin/shortcuts/storage.rb
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #__ ⇒ Object
- #add(name, shortcut) ⇒ Object
- #add_from(other) ⇒ Object
- #g(middlewares: Grumlin.default_middlewares) ⇒ Object
-
#initialize(storage = {}) ⇒ Storage
constructor
A new instance of Storage.
- #step_class ⇒ Object
- #traversal_start_class ⇒ Object
Constructor Details
#initialize(storage = {}) ⇒ Storage
Returns a new instance of Storage.
16 17 18 19 20 21 |
# File 'lib/grumlin/shortcuts/storage.rb', line 16 def initialize(storage = {}) @storage = storage storage.each do |n, s| add(n, s) end end |
Class Method Details
.[](other) ⇒ Object
7 8 9 |
# File 'lib/grumlin/shortcuts/storage.rb', line 7 def [](other) new(other) end |
.empty ⇒ Object
11 12 13 |
# File 'lib/grumlin/shortcuts/storage.rb', line 11 def empty @empty ||= new end |
Instance Method Details
#==(other) ⇒ Object
28 29 30 |
# File 'lib/grumlin/shortcuts/storage.rb', line 28 def ==(other) @storage == other.storage end |
#__ ⇒ Object
53 54 55 |
# File 'lib/grumlin/shortcuts/storage.rb', line 53 def __ traversal_start_class.new end |
#add(name, shortcut) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/grumlin/shortcuts/storage.rb', line 32 def add(name, shortcut) @storage[name] = shortcut sc = step_class shortcut_methods_module.define_method(name) do |*args, **params| next sc.new(name, args:, params:, previous_step: self, pool:) end extend_traversal_classes(shortcut) unless shortcut.lazy? end |
#add_from(other) ⇒ Object
43 44 45 46 47 |
# File 'lib/grumlin/shortcuts/storage.rb', line 43 def add_from(other) other.storage.each do |name, shortcut| add(name, shortcut) end end |
#g(middlewares: Grumlin.default_middlewares) ⇒ Object
49 50 51 |
# File 'lib/grumlin/shortcuts/storage.rb', line 49 def g(middlewares: Grumlin.default_middlewares) traversal_start_class.new(pool: Grumlin.default_pool, middlewares:) end |
#step_class ⇒ Object
61 62 63 |
# File 'lib/grumlin/shortcuts/storage.rb', line 61 def step_class @step_class ||= shortcut_aware_class(Grumlin::Step) end |
#traversal_start_class ⇒ Object
57 58 59 |
# File 'lib/grumlin/shortcuts/storage.rb', line 57 def traversal_start_class @traversal_start_class ||= shortcut_aware_class(Grumlin::TraversalStart) end |