Sha256: 0569dac94c419cee9b86e12ee45eda5b94f2a335a48e914e234902e404e70ce1

Contents?: true

Size: 517 Bytes

Versions: 15

Compression:

Stored size: 517 Bytes

Contents

# frozen_string_literal: true

class Grumlin::Shortcut
  extend Forwardable

  attr_reader :name, :block

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

  def initialize(name, lazy: true, &block)
    @name = name
    @lazy = lazy
    @block = block
  end

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

  def lazy?
    @lazy
  end

  # TODO: to_s, inspect, preview

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
grumlin-1.2.0 lib/grumlin/shortcut.rb
grumlin-1.1.0 lib/grumlin/shortcut.rb
grumlin-1.0.4 lib/grumlin/shortcut.rb
grumlin-1.0.3 lib/grumlin/shortcut.rb
grumlin-1.0.3.beta1 lib/grumlin/shortcut.rb
grumlin-1.0.2 lib/grumlin/shortcut.rb
grumlin-1.0.1 lib/grumlin/shortcut.rb
grumlin-1.0.0 lib/grumlin/shortcut.rb
grumlin-1.0.0.rc7 lib/grumlin/shortcut.rb
grumlin-1.0.0.rc6 lib/grumlin/shortcut.rb
grumlin-1.0.0.rc5 lib/grumlin/shortcut.rb
grumlin-1.0.0.rc4 lib/grumlin/shortcut.rb
grumlin-1.0.0.rc3 lib/grumlin/shortcut.rb
grumlin-1.0.0.rc2 lib/grumlin/shortcut.rb
grumlin-1.0.0.rc1 lib/grumlin/shortcut.rb