lib/grumlin/shortcuts.rb in grumlin-0.23.0 vs lib/grumlin/shortcuts.rb in grumlin-1.0.0.rc1

- old
+ new

@@ -1,36 +1,34 @@ # frozen_string_literal: true -module Grumlin - module Shortcuts - def self.extended(base) - base.include(Grumlin::Expressions) - end +module Grumlin::Shortcuts + def self.extended(base) + base.include(Grumlin::Expressions) + end - def inherited(subclass) - super - subclass.shortcuts_from(self) - end + def inherited(subclass) + super + subclass.shortcuts_from(self) + end - def shortcut(name, shortcut = nil, override: false, lazy: true, &block) - name = name.to_sym - lazy = false if override + 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 + 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 + raise ArgumentError, "either shortcut or block must be passed" if [shortcut, block].count(&:nil?) != 1 - shortcuts.add(name, shortcut || Shortcut.new(name, lazy: lazy, &block)) - end + shortcuts.add(name, shortcut || Grumlin::Shortcut.new(name, lazy: lazy, &block)) + end - def shortcuts_from(other_shortcuts) - shortcuts.add_from(other_shortcuts.shortcuts) - end + def shortcuts_from(other_shortcuts) + shortcuts.add_from(other_shortcuts.shortcuts) + end - def shortcuts - @shortcuts ||= Storage.new - end + def shortcuts + @shortcuts ||= Storage.new end end