Sha256: 47354a82cfdfa7d47647c862d4bf516238b911e7c34192e5457d98dd5d1ba09b

Contents?: true

Size: 671 Bytes

Versions: 2

Compression:

Stored size: 671 Bytes

Contents

require "binding_ninja/version"
require "binding_ninja/binding_ninja"

module BindingNinja
  def auto_inject_binding_options
    {}
  end

  METHOD_DEFINER = ->(klass) do
    unless klass.method_defined?(:auto_inject_binding_options)
      options = {}
      klass.class_eval do
        @auto_inject_binding_options = options
      end

      klass.define_singleton_method(:auto_inject_binding_options) do
        super().merge(options)
      end
    end
  end

  def inherited(klass)
    super
    METHOD_DEFINER.call(klass)
  end

  def included(klass)
    super
    METHOD_DEFINER.call(klass)
  end

  def self.extended(klass)
    METHOD_DEFINER.call(klass)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
binding_ninja-0.2.2 lib/binding_ninja.rb
binding_ninja-0.2.1 lib/binding_ninja.rb