Class: GObjectIntrospection::Loader::Invoker

Inherits:
Object
  • Object
show all
Defined in:
lib/gobject-introspection/loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(info, method_name, full_method_name) ⇒ Invoker

Returns a new instance of Invoker.



587
588
589
590
591
592
# File '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

Instance Method Details

#invoke(receiver, arguments, block) ⇒ Object



594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
# File '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(invoke_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