File: strong_reference.rb

package info (click to toggle)
ruby-ref 1.0.5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 332 kB
  • ctags: 186
  • sloc: ruby: 1,107; java: 92; makefile: 2
file content (17 lines) | stat: -rw-r--r-- 445 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module Ref
  # This implementation of Reference holds a strong reference to an object. The
  # referenced object will not be garbage collected as long as the strong reference
  # exists.
  class StrongReference < Reference
    # Create a new strong reference to an object.
    def initialize(obj)
      @obj = obj
      @referenced_object_id = obj.__id__
    end
    
    # Get the referenced object.
    def object
      @obj
    end
  end
end