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.



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

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



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

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

#__getobj__Object



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

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

#__reload__Object



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

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

#__version__Object



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

def __version__
  @lock.with_read_lock do
    @version
  end
end

#inspectObject



54
55
56
57
58
59
60
61
# File 'lib/alki/assembly/instance.rb', line 54

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



63
64
65
# File 'lib/alki/assembly/instance.rb', line 63

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

#to_sObject



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

def to_s
  inspect
end