Class: RPCQooxdooService
Constant Summary collapse
- @@services_hash =
{}
- @@needs =
{}
- @@is_instance =
false
Class Method Summary collapse
-
.add_prime_service(subclass, name) ⇒ Object
Adds a new service of type “subclass” and stores it under “name”.
- .entities ⇒ Object
-
.inherited(subclass) ⇒ Object
Catches the name of the new class.
- .migrate_all ⇒ Object
- .needs ⇒ Object
- .services ⇒ Object
Instance Method Summary collapse
- #get_services(services = '.*') ⇒ Object
-
#initialize(services = '.*') ⇒ RPCQooxdooService
constructor
As we can’t call .new during “inherited”, we have to do it afterwards - too bad.
- #needs_covered(a) ⇒ Object
Constructor Details
#initialize(services = '.*') ⇒ RPCQooxdooService
As we can’t call .new during “inherited”, we have to do it afterwards - too bad.
46 47 48 |
# File 'lib/qooxview/rpcqooxdoo.rb', line 46 def initialize(services = '.*') get_services(services) end |
Class Method Details
.add_prime_service(subclass, name) ⇒ Object
Adds a new service of type “subclass” and stores it under “name”
138 139 140 141 142 |
# File 'lib/qooxview/rpcqooxdoo.rb', line 138 def self.add_prime_service(subclass, name) dputs(5) { "Add a new service: #{subclass} as #{name}" } @@services_hash[name] = subclass.new @@services_hash[name].load(false) end |
.entities ⇒ Object
108 109 110 111 112 113 114 115 |
# File 'lib/qooxview/rpcqooxdoo.rb', line 108 def self.entities RPCQooxdooService.services.each { |service_name, service_class| if service_name.to_s =~ /^Entities/ dputs(4) { "Found Entities of #{service_name.inspect}" } yield service_class end } end |
.inherited(subclass) ⇒ Object
Catches the name of the new class
118 119 120 121 122 123 124 125 126 127 |
# File 'lib/qooxview/rpcqooxdoo.rb', line 118 def self.inherited(subclass) # name = "#{subclass}".sub( /^.*?_/, "" ).gsub( '_', '.' ) name = "#{subclass}".gsub('_', '.') super_name = subclass.superclass.name if super_name != 'RPCQooxdooService' name = "#{super_name}.#{name}" end dputs(5) { "A new handler -#{subclass} is created for the class: #{super_name} with path #{name}" } @@services_hash[name] = subclass end |
.migrate_all ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/qooxview/rpcqooxdoo.rb', line 94 def self.migrate_all # And now do eventual migrations on everybody @@services_hash.each_pair { |k, v| if k =~ /^Entities/ and v.class != Class dputs(3) { "Migration of #{k}" } oldload = v.loading v.loading = true v.migrate v.loading = oldload dputs(3) { "Migration of #{k}" } end } end |
.needs ⇒ Object
133 134 135 |
# File 'lib/qooxview/rpcqooxdoo.rb', line 133 def self.needs @@needs end |
.services ⇒ Object
129 130 131 |
# File 'lib/qooxview/rpcqooxdoo.rb', line 129 def self.services @@services_hash end |
Instance Method Details
#get_services(services = '.*') ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/qooxview/rpcqooxdoo.rb', line 58 def get_services(services = '.*') #dputs_func do_init = true while do_init do_init = false dputs(3) { "List is: #{@@services_hash.keys.inspect} for services #{services.inspect}" } # The entities have to be initialized before the views %w(Entities View).each { |e| @@services_hash.sort.each { |k, v| if k =~ /^#{e}/ and k =~ /#{services}/ dputs(3) { "Initializing #{k.class.name} with #{v.class.name}" } if @@services_hash[k].class == Class dputs(5) { "Needs is: #{@@needs.inspect}" } #if @@needs.has_key?(k) && # @@services_hash[@@needs[k]].class == Class if !needs_covered(k) dputs(3) { "Not initializing #{k}, as it needs #{@@needs[k]}" } @@needs[k].each { |n| get_services(/^#{n}$/) } do_init = true else dputs(3) { "RPC: making an instance of #{k.inspect} with #{v.inspect}" } @@services_hash[k] = v.new end end end } } end @@is_instance = true end |
#needs_covered(a) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/qooxview/rpcqooxdoo.rb', line 50 def needs_covered(a) return true unless @@needs.has_key?(a) @@needs[a].each { |n| return false if @@services_hash[n].class == Class } return true end |