Sha256: 5d05d73538b8ffd04618d7a96857e7f2021280962c8d55d6598882cf3f99262c

Contents?: true

Size: 740 Bytes

Versions: 2

Compression:

Stored size: 740 Bytes

Contents

module Invokr
  extend self

  def invoke args = {}
    method_name, obj, hsh_args = require_arguments! args, :method, :on, :with
    method = obj.method method_name
    invocation = Builder.build method, hsh_args, args[:block]
    invocation.invoke! obj
  end

  def query_method method
    Method.new method
  end

  private

  def require_arguments! hsh, *args
    found_args, missing_args = args.partition do |arg|
      hsh.has_key? arg
    end
    raise InputError.new missing_args unless missing_args.empty?
    found_args.map { |arg| hsh.fetch arg }
  end
end

require_relative 'invokr/builder'
require_relative 'invokr/errors'
require_relative 'invokr/invocation'
require_relative 'invokr/method'
require_relative 'invokr/version'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
invokr-0.0.5 lib/invokr.rb
invokr-0.0.4 lib/invokr.rb