Class: Role

Inherits:
Object
  • Object
show all
Defined in:
lib/role.rb

Direct Known Subclasses

DbRole, ProxyRole, RailsRole, StatsRole

Constant Summary collapse

INDEX =
{}

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manifest) ⇒ Role

Returns a new instance of Role.



29
30
31
# File 'lib/role.rb', line 29

def initialize(manifest)
  @manifest = manifest
end

Class Attribute Details

.my_roleObject

Returns the value of attribute my_role.



19
20
21
# File 'lib/role.rb', line 19

def my_role
  @my_role
end

Class Method Details

.get_role(msg) ⇒ Object



8
9
10
11
12
# File 'lib/role.rb', line 8

def get_role(msg)
  role = INDEX[msg['role']].new(msg)
  role.start
  role
end

.role(name) ⇒ Object



14
15
16
17
# File 'lib/role.rb', line 14

def role(name)
  INDEX[name] = self
  self.my_role = name
end

Instance Method Details

#disableObject

Raises:

  • (NotImplementedError)


41
42
43
# File 'lib/role.rb', line 41

def disable
  raise NotImplementedError
end

Raises:

  • (NotImplementedError)


49
50
51
# File 'lib/role.rb', line 49

def disable_link(type, addr)
  raise NotImplementedError
end

#enableObject

Raises:

  • (NotImplementedError)


45
46
47
# File 'lib/role.rb', line 45

def enable
  raise NotImplementedError
end

Raises:

  • (NotImplementedError)


53
54
55
# File 'lib/role.rb', line 53

def enable_link(type, addr)
  raise NotImplementedError
end


57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/role.rb', line 57

def init_links(type, links, &block)
  @active_links ||= {}
  @active_links[type] ||= (links || [])

  @broken_links ||= {}
  @broken_links[type] ||= []

  @disabled_links ||= {}
  @disabled_links[type] ||= []

  @event_callbacks ||= {}
  @event_callbacks[type] = block
end

#startObject

Raises:

  • (NotImplementedError)


33
34
35
# File 'lib/role.rb', line 33

def start
  raise NotImplementedError
end

#stateObject



22
23
24
25
26
27
# File 'lib/role.rb', line 22

def state
  { 'role' => self.class.my_role,
    'active' => @active_links,
    'disabled' => @disabled_links,
    'broken' => @broken_links }
end

#stopObject

Raises:

  • (NotImplementedError)


37
38
39
# File 'lib/role.rb', line 37

def stop
  raise NotImplementedError
end