lib/openwfe/contextual.rb in openwferu-0.9.7 vs lib/openwfe/contextual.rb in openwferu-0.9.8

- old
+ new

@@ -56,17 +56,19 @@ # Looks up something in the application context, if the given # key is a class, then the first value in the context of that # class is returned. # def lookup (key) + if key.kind_of? Class @application_context.each do |k, value| return value if value.class == key end return nil end - return @application_context[key] + + @application_context[key] end # # Use reflection to instantiate the new service,and # add it to the application context @@ -75,15 +77,15 @@ # def init_service (service_name, service_class) s = service_class.new(service_name, @application_context) - s.service_name = "#{service_class.name}::#{s.object_id}" \ - unless service_name + unless service_name + s.service_name = "#{service_class.name}::#{s.object_id}" + @application_context[s.service_name.to_s] = s + end - @application_context[s.service_name.to_s] = s - - return s + s end end end