Skip to content

Instantly share code, notes, and snippets.

@abstractj
Created August 11, 2011 17:31
Show Gist options
  • Save abstractj/1140245 to your computer and use it in GitHub Desktop.
Save abstractj/1140245 to your computer and use it in GitHub Desktop.
service_injection_demo
class MyController < ApplicationController
include TorqueBox::Injectors
def index
service = inject('service:MyService')
end
end
class MyService
def initialize(opts={})
@name = opts['name']
end
def start
Thread.new { run }
end
def stop
@done = true
end
def run
until @done
puts "Hello #{@name}"
sleep(1)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment