Module: Grumlin::Shortcuts
- Included in:
- Properties, Upserts
- Defined in:
- lib/grumlin/shortcuts.rb
Defined Under Namespace
Modules: Properties, Upserts Classes: Storage
Class Method Summary collapse
Instance Method Summary collapse
- #inherited(subclass) ⇒ Object
- #shortcut(name, shortcut = nil, override: false, lazy: true, &block) ⇒ Object
- #shortcuts ⇒ Object
- #shortcuts_from(other_shortcuts) ⇒ Object
Class Method Details
.extended(base) ⇒ Object
4 5 6 |
# File 'lib/grumlin/shortcuts.rb', line 4 def self.extended(base) base.include(Grumlin::Expressions) end |
Instance Method Details
#inherited(subclass) ⇒ Object
8 9 10 11 |
# File 'lib/grumlin/shortcuts.rb', line 8 def inherited(subclass) super subclass.shortcuts_from(self) end |
#shortcut(name, shortcut = nil, override: false, lazy: true, &block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/grumlin/shortcuts.rb', line 13 def shortcut(name, shortcut = nil, override: false, lazy: true, &block) name = name.to_sym lazy = false if override if Grumlin::Step::REGULAR_STEPS.include?(name) && !override raise ArgumentError, "overriding standard gremlin steps is not allowed, if you know what you're doing, pass `override: true`" end raise ArgumentError, "either shortcut or block must be passed" if [shortcut, block].count(&:nil?) != 1 shortcuts.add(name, shortcut || Grumlin::Shortcut.new(name, lazy:, &block)) end |
#shortcuts ⇒ Object
31 32 33 |
# File 'lib/grumlin/shortcuts.rb', line 31 def shortcuts @shortcuts ||= Storage.new end |
#shortcuts_from(other_shortcuts) ⇒ Object
27 28 29 |
# File 'lib/grumlin/shortcuts.rb', line 27 def shortcuts_from(other_shortcuts) shortcuts.add_from(other_shortcuts.shortcuts) end |