HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/local/rvm/gems/ruby-2.5.9/doc/thor-1.1.0/ri/Thor/Invocation/invoke-i.ri
U:RDoc::AnyMethod[iI"invoke:ETI"Thor::Invocation#invoke;TF:publico:RDoc::Markup::Document:@parts[ o:RDoc::Markup::Paragraph;	[I"SReceives a name and invokes it. The name can be a string (either "command" or ;TI"O"namespace:command"), a Thor::Command, a Class or a Thor instance. If the ;TI"Scommand cannot be guessed by name, it can also be supplied as second argument.;To:RDoc::Markup::BlankLineo;
;	[I"MYou can also supply the arguments, options and configuration values for ;TI"Jthe command to be invoked, if none is given, the same values used to ;TI"?initialize the invoker are used to initialize the invoked.;T@o;
;	[I"TWhen no name is given, it will invoke the default command of the current class.;T@S:RDoc::Markup::Heading:
leveli	:	textI"
Examples;T@o:RDoc::Markup::Verbatim;	[I"class A < Thor
;TI"  def foo
;TI"    invoke :bar
;TI"$    invoke "b:hello", ["Erik"]
;TI"  end
;TI"
;TI"  def bar
;TI"$    invoke "b:hello", ["Erik"]
;TI"  end
;TI"	end
;TI"
;TI"class B < Thor
;TI"  def hello(name)
;TI"    puts "hello #{name}"
;TI"  end
;TI"	end
;T:@format0o;
;	[I"MYou can notice that the method "foo" above invokes two commands: "bar", ;TI"Nwhich belongs to the same class and "hello" which belongs to the class B.;T@o;
;	[I"SBy using an invocation system you ensure that a command is invoked only once. ;TI"PIn the example above, invoking "foo" will invoke "b:hello" just once, even ;TI"+if it's invoked later by "bar" method.;T@o;
;	[I"NWhen class A invokes class B, all arguments used on A initialization are ;TI"Nsupplied to B. This allows lazy parse of options. Let's suppose you have ;TI"some rspec commands:;T@o;;	[I"class Rspec < Thor::Group
;TI"G  class_option :mock_framework, :type => :string, :default => :rr
;TI"
;TI"!  def invoke_mock_framework
;TI"4    invoke "rspec:#{options[:mock_framework]}"
;TI"  end
;TI"	end
;T;0o;
;	[I"OAs you noticed, it invokes the given mock framework, which might have its ;TI"own options:;T@o;;	[I"#class Rspec::RR < Thor::Group
;TI"@  class_option :style, :type => :string, :default => :mock
;TI"	end
;T;0o;
;	[I"KSince it's not rspec concern to parse mock framework options, when RR ;TI"Qis invoked all options are parsed again, so RR can extract only the options ;TI"that it's going to use.;T@o;
;	[I"NIf you want Rspec::RR to be initialized with its own set of options, you ;TI" have to do that explicitly:;T@o;;	[I"+invoke "rspec:rr", [], :style => :foo
;T;0o;
;	[I"EBesides giving an instance, you can also give a class to invoke:;T@o;;	[I")invoke Rspec::RR, [], :style => :foo;T;0:
@fileI"lib/thor/invocation.rb;T:0@omit_headings_from_table_of_contents_below000[I"(name = nil, *args);T@_FI"Invocation;TcRDoc::NormalModule00