# File lib/ruote/context.rb, line 108 def add_service (key, *args) path, klass, opts = args key = "s_#{key}" unless SERVICE_PREFIX.match(key) service = if klass require(path) if path aa = [ self ] aa << opts if opts @services[key] = Ruote.constantize(klass).new(*aa) else @services[key] = path end self.class.class_eval %{ def #{key[2..-1]}; @services['#{key}']; end } # # This 'one-liner' will add an instance method to Context for this # service. # # If the service key is 's_dishwasher', then the service will be # available via Context#dishwasher. # # I.e. dishwasher = engine.context.dishwasher service end