module Celluloid::InstanceMethods

These are methods we don't want added to the Celluloid singleton but to be defined on all classes that use Celluloid

Public Instance Methods

__arity() click to toggle source
# File lib/celluloid.rb, line 306
def __arity
  method(:initialize).arity
end
bare_object() click to toggle source

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 263
def bare_object
  self
end
Also aliased as: wrapped_object
inspect() click to toggle source
# File lib/celluloid.rb, line 284
def inspect
  return "..." if Celluloid.detect_recursion

  str = "#<"

  if leaked?
    str << Celluloid::BARE_OBJECT_WARNING_MESSAGE
  else
    str << "Celluloid::Proxy::Cell"
  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
leaked?() click to toggle source

Are we being invoked in a different thread from our owner?

# File lib/celluloid.rb, line 269
def leaked?
  @celluloid_owner != Thread.current[:celluloid_actor]
end
name()
Alias for: registered_name
registered_name() click to toggle source

Obtain the name of the current actor

# File lib/celluloid.rb, line 279
def registered_name
  Actor.registered_name
end
Also aliased as: name
tap() { |current_actor| ... } click to toggle source
# File lib/celluloid.rb, line 273
def tap
  yield current_actor
  current_actor
end
wrapped_object()
Alias for: bare_object