Sha256: c79b8e8560ce911b81f68c2200abad16a38c940bcdd73c61f96fa80b23de77b0

Contents?: true

Size: 503 Bytes

Versions: 14

Compression:

Stored size: 503 Bytes

Contents

# frozen_string_literal: true

module Grumlin
  class Shortcut
    extend Forwardable

    attr_reader :name, :block

    def_delegator :@block, :arity
    def_delegator :@block, :source_location

    def initialize(name, &block)
      @name = name
      @block = block
    end

    def ==(other)
      @name == other.name && @block == other.block
    end

    # TODO: to_s, inspect, preview

    def apply(object, *args, **params)
      object.instance_exec(*args, **params, &@block)
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
grumlin-0.19.7 lib/grumlin/shortcut.rb
grumlin-0.19.6 lib/grumlin/shortcut.rb
grumlin-0.19.5 lib/grumlin/shortcut.rb
grumlin-0.19.4 lib/grumlin/shortcut.rb
grumlin-0.19.3 lib/grumlin/shortcut.rb
grumlin-0.19.2 lib/grumlin/shortcut.rb
grumlin-0.19.1 lib/grumlin/shortcut.rb
grumlin-0.19.0 lib/grumlin/shortcut.rb
grumlin-0.18.1 lib/grumlin/shortcut.rb
grumlin-0.18.0 lib/grumlin/shortcut.rb
grumlin-0.17.0 lib/grumlin/shortcut.rb
grumlin-0.16.1 lib/grumlin/shortcut.rb
grumlin-0.16.0 lib/grumlin/shortcut.rb
grumlin-0.15.6 lib/grumlin/shortcut.rb