These are methods we don't want added to the Celluloid singleton but to be defined on all classes that use Celluloid
Obtain the bare Ruby object the actor is wrapping. This is useful for only a limited set of use cases like runtime metaprogramming. Interacting directly with the bare object foregoes any kind of thread safety that Celluloid would ordinarily provide you, and the object is guaranteed to be shared with at least the actor thread. Tread carefully.
Bare objects can be identified via inspect output:
>> actor => #<Celluloid::Actor(Foo:0x3fefcb77c194)> >> actor.bare_object => #<WARNING: BARE CELLULOID OBJECT (Foo:0x3fefcb77c194)>
# File lib/celluloid.rb, line 310 def bare_object; self; end
# File lib/celluloid.rb, line 328 def inspect str = "#<" if leaked? str << Celluloid::BARE_OBJECT_WARNING_MESSAGE else str << "Celluloid::ActorProxy" end str << "(#{self.class}:0x#{object_id.to_s(16)})" str << " " unless instance_variables.empty? instance_variables.each do |ivar| next if ivar == Celluloid::OWNER_IVAR str << "#{ivar}=#{instance_variable_get(ivar).inspect} " end str.sub!(/\s$/, '>') end
Are we being invoked in a different thread from our owner?
# File lib/celluloid.rb, line 314 def leaked? @celluloid_owner != Thread.current[:celluloid_actor] end
Process async calls via method_missing
# File lib/celluloid/legacy.rb, line 21 def method_missing(meth, *args, &block) # bang methods are async calls if meth.to_s.match(/!$/) Logger.deprecate("'bang method'-style async syntax is deprecated and will be removed in Celluloid 1.0." + "Call async methods with 'actor.async.method'.") unbanged_meth = meth.to_s.sub(/!$/, '') args.unshift unbanged_meth async :__send__, *args, &block return end super end
Obtain the name of the current actor
# File lib/celluloid.rb, line 324 def name Actor.name end
Generated with the Darkfish Rdoc Generator 2.