class GObjectIntrospection::Loader::Invoker

Public Class Methods

new(info, method_name, full_method_name) click to toggle source
# File gobject-introspection/lib/gobject-introspection/loader.rb, line 587
def initialize(info, method_name, full_method_name)
  @info = info
  @method_name = method_name
  @full_method_name = full_method_name
  @prepared = false
end

Public Instance Methods

invoke(receiver, arguments, block) click to toggle source
# File gobject-introspection/lib/gobject-introspection/loader.rb, line 594
def invoke(receiver, arguments, block)
  ensure_prepared

  if receiver and @function_info_p
    arguments.unshift(receiver)
  end

  arguments, block = build(receiver, arguments, block)
  unless valid?(arguments)
    if @on_invalid == :fallback
      return @value_on_invalid
    else
      raise ArgumentError, invalid_error_message(arguments)
    end
  end

  if block.nil? and @require_callback_p
    receiver.to_enum(@method_name, *arguments)
  else
    if @function_info_p
      return_value = @info.invoke(arguments, &block)
    else
      return_value = @info.invoke(receiver, arguments, &block)
    end
    if @have_return_value_p
      return_value
    else
      receiver
    end
  end
end