Class: Goz::Service::FakeService
- Defined in:
- lib/goz/service/fake_service.rb
Overview
Constant Summary collapse
- FN =
'fake_service_database.yaml'
- TAG =
self.name
- @@registry =
nil
Class Method Summary collapse
-
.create(g) ⇒ Object
XXX ALL UGLY HACKS!.
- .destroy(g) ⇒ Object
- .load_registry ⇒ Object
- .save_registry ⇒ Object
- .sync_group(g, s) ⇒ Object
Methods inherited from Base
Class Method Details
.create(g) ⇒ Object
XXX ALL UGLY HACKS!
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/goz/service/fake_service.rb', line 34 def self.create(g) Goz::Logger.debug TAG, "create( group.name=#{g.name} )" load_registry if @@registry.key? g.name Goz::Logger.info TAG, "create( group.name=#{g.name} ) - group exists" return true end Goz::Logger.info TAG, "create( group.name=#{g.name} ) - creating group" @@registry[ g.name ] = { :group => g.to_hash } save_registry end |
.destroy(g) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/goz/service/fake_service.rb', line 55 def self.destroy(g) Goz::Logger.debug TAG, "destroy( group.name=#{g.name} )" load_registry unless @@registry.key? g.name Goz::Logger.info TAG, "destroy( group.name=#{g.name} ) - does not exist" return true end Goz::Logger.info TAG, "destroy( group.name=#{g.name} ) - deleting group" @@registry.delete g.name save_registry end |
.load_registry ⇒ Object
46 47 48 49 |
# File 'lib/goz/service/fake_service.rb', line 46 def self.load_registry return @@registry unless @@registry.nil? @@registry = File.exist?(FN) ? YAML.load_file(FN) : {} end |
.save_registry ⇒ Object
51 52 53 |
# File 'lib/goz/service/fake_service.rb', line 51 def self.save_registry File.open(FN, 'w') { |fh| fh.write YAML.dump(@@registry) } end |
.sync_group(g, s) ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/goz/service/fake_service.rb', line 67 def self.sync_group(g, s) Goz::Logger.debug TAG, "sync_group( group.name=#{g.name}, service.name=#{s.name} )" load_registry create(g) unless @@registry.key? g.name @@registry[ g.name ][ :admins ] = {} @@registry[ g.name ][ :members ] = {} g.admins.each { |u| @@registry[ g.name ][:admins][ u.login ] = u.to_hash } g.members.each { |u| @@registry[ g.name ][:members][ u.login ] = u.to_hash } save_registry end |