Class: Evma::Container

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/evma/container.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContainer

Returns a new instance of Container.



38
39
40
# File 'lib/evma/container.rb', line 38

def initialize
  @objects = {}
end

Class Method Details

.callback(target, opcode, data) ⇒ Object



46
47
48
# File 'lib/evma/container.rb', line 46

def self.callback target, opcode, data
  instance.callback target, opcode, data
end

.store(obj) ⇒ Object



42
43
44
# File 'lib/evma/container.rb', line 42

def self.store obj
  instance.store obj
end

Instance Method Details

#callback(target, opcode, data) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/evma/container.rb', line 56

def callback target, opcode, data
  case opcode
  when 101 # received data
    obj = @objects[target] or raise UnknownTarget.new( target )
    obj.receive_data data
  when 102 # unbind
    obj = @objects[target] or raise UnknownTarget.new( target )
    obj.unbind
    @objects.delete obj.signature
  when 103 # accept
    obj = @objects[target] or raise UnknownTarget.new( target )
    obj.accept data
  else
    raise UnsupportedCallback.new( opcode.to_s )
  end
end

#store(obj) ⇒ Object

Raises:



50
51
52
53
54
# File 'lib/evma/container.rb', line 50

def store obj
  sig = obj.signature
  raise ContainerHasObject.new(sig) if @objects.has_key?(sig)
  @objects[sig] = obj
end