Class: Alki::Assembly::Instance

Inherits:
Delegator
  • Object
show all
Defined in:
lib/alki/assembly/instance.rb

Instance Method Summary collapse

Constructor Details

#initialize(assembly_module, overrides) ⇒ Instance

Returns a new instance of Instance.



10
11
12
13
14
15
16
17
18
# File 'lib/alki/assembly/instance.rb', line 10

def initialize(assembly_module,overrides)
  @assembly_module = assembly_module
  @overrides = overrides
  @version = 0
  @needs_load = true
  @lock = Concurrent::ReentrantReadWriteLock.new
  @obj = nil
  @executor = nil
end

Instance Method Details

#__executor__Object



43
44
45
46
47
48
# File 'lib/alki/assembly/instance.rb', line 43

def __executor__
  @lock.with_read_lock do
    __load__ if @needs_load
    @executor
  end
end

#__getobj__Object



50
51
52
53
54
55
# File 'lib/alki/assembly/instance.rb', line 50

def __getobj__
  @lock.with_read_lock do
    __load__ if @needs_load
    @obj
  end
end

#__reload__Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/alki/assembly/instance.rb', line 20

def __reload__
  @lock.with_read_lock do
    unless @needs_load
      @lock.with_write_lock do
        @version += 1
        @needs_load = true
      end
    end
  end
end

#__reloading__Object



31
32
33
34
35
# File 'lib/alki/assembly/instance.rb', line 31

def __reloading__
  @lock.with_read_lock do
    @needs_load
  end
end

#__version__Object



37
38
39
40
41
# File 'lib/alki/assembly/instance.rb', line 37

def __version__
  @lock.with_read_lock do
    @version
  end
end

#inspectObject



61
62
63
64
65
66
67
68
# File 'lib/alki/assembly/instance.rb', line 61

def inspect
  if @assembly_module.is_a?(Module)
    name = @assembly_module.name || 'AnonymousAssembly'
  else
    name = Alki::Support.classify(@assembly_module.to_s)
  end
  "#<#{name}:#{object_id}>"
end

#pretty_print(q) ⇒ Object



70
71
72
# File 'lib/alki/assembly/instance.rb', line 70

def pretty_print(q)
  q.text(inspect)
end

#to_sObject



57
58
59
# File 'lib/alki/assembly/instance.rb', line 57

def to_s
  inspect
end