Module: Celluloid::InstanceMethods
- Defined in:
- lib/celluloid.rb
Overview
These are methods we don’t want added to the Celluloid singleton but to be defined on all classes that use Celluloid
Instance Method Summary collapse
- #__arity ⇒ Object
-
#bare_object ⇒ Object
(also: #wrapped_object)
Obtain the bare Ruby object the actor is wrapping.
- #inspect ⇒ Object
-
#leaked? ⇒ Boolean
Are we being invoked in a different thread from our owner?.
-
#registered_name ⇒ Object
(also: #name)
Obtain the name of the current actor.
- #tap {|current_actor| ... } ⇒ Object
Instance Method Details
#__arity ⇒ Object
309 310 311 |
# File 'lib/celluloid.rb', line 309 def __arity method(:initialize).arity end |
#bare_object ⇒ Object Also known as: wrapped_object
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)>
266 267 268 |
# File 'lib/celluloid.rb', line 266 def self end |
#inspect ⇒ Object
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/celluloid.rb', line 287 def inspect return "..." if Celluloid.detect_recursion str = "#<" str << if leaked? Celluloid::BARE_OBJECT_WARNING_MESSAGE else "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? ⇒ Boolean
Are we being invoked in a different thread from our owner?
272 273 274 |
# File 'lib/celluloid.rb', line 272 def leaked? @celluloid_owner != Thread.current[:celluloid_actor] end |
#registered_name ⇒ Object Also known as: name
Obtain the name of the current actor
282 283 284 |
# File 'lib/celluloid.rb', line 282 def registered_name Actor.registered_name end |
#tap {|current_actor| ... } ⇒ Object
276 277 278 279 |
# File 'lib/celluloid.rb', line 276 def tap yield current_actor current_actor end |