Skip to content

Instantly share code, notes, and snippets.

@niklas
Forked from kronn/applied_concept.rb
Created September 8, 2011 11:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niklas/1203179 to your computer and use it in GitHub Desktop.
Save niklas/1203179 to your computer and use it in GitHub Desktop.
current_scheduler = scheduler(:availabilities)
def current_scheduler.handle_exception(job, exception)
Airbrake.do_the_right_thing(exception, other_params)
puts "job #{job.job_id} caught exception '#{exception}' - the Airbrake has been triggered"
end
class TaskManager
# [..]
# do you think this may work? (hoptoad_options scope)
def scheduler(key)
hoptoad_options = { :environment_name => @env }
@schedulers[key] ||= Rufus::Scheduler.start_new.tap do |scheduler|
def scheduler.handle_exception(job, exception)
HoptoadNotifier.notify(exception, hoptoad_options.merge(:parameters => { :job => job }))
say "job #{job.job_id} caught exception '#{exception}' - the Airbrake has been triggered"
end
end
end
end
@cache = {}
def get(name)
@cache[name] ||= Array.new
end
# just to clarify, what get(name) does:
# it manages object references
get(:one) == get(:one)
get(:two) != get(:one)
get(:one) != []
one = get(:one)
def one.chunky
"bacon" * self.size
end
one.respond_to? :chunky
one.chunky # => ''
get(:one) << 'say it'
one.chunky # "bacon"
get(:two).respond_to? :chunky # => false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment