Class: KingSoa::Registry

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/king_soa/registry.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.<<(service) ⇒ Object

add a service



14
15
16
# File 'lib/king_soa/registry.rb', line 14

def self.<<(service)
  instance << service
end

.[](service_name) ⇒ Object

Get a method by a given name



10
11
12
# File 'lib/king_soa/registry.rb', line 10

def self.[](service_name)
  instance[service_name]
end

.group(name) ⇒ Object

find a group of services identified by starting with the same string



24
25
26
# File 'lib/king_soa/registry.rb', line 24

def self.group(name)
  instance.group(name)
end

.servicesObject

Return an array of defined services



18
19
20
# File 'lib/king_soa/registry.rb', line 18

def self.services
  instance.services
end

Instance Method Details

#<<(service) ⇒ Object

Add a new service onto the stack

Parameter

service<KingSoa::Service>

the service to add



39
40
41
# File 'lib/king_soa/registry.rb', line 39

def <<(service)
  (services || []) << service
end

#[](service_name) ⇒ Object

Get a method by a given name

Parameter

service_name<String|Symbol>

the service to find

Returns

<KingSoa::Service> or <nil>



48
49
50
51
# File 'lib/king_soa/registry.rb', line 48

def [](service_name)
  name = service_name.to_sym
  services.detect {|s| s.name == name }
end

#group(service_name) ⇒ Object

untested



54
55
56
# File 'lib/king_soa/registry.rb', line 54

def group(service_name)
  services.select {|s| !s.name.to_s.match(/^#{service_name}/).nil? }
end

#servicesObject

returns all available methods



32
33
34
# File 'lib/king_soa/registry.rb', line 32

def services
  @services ||= []
end