Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: frison/url_job
base: d1a09e0143
...
head fork: frison/url_job
compare: 917b0be62f
  • 2 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
2  CHANGELOG
@@ -1,3 +1,5 @@
+0.0.3
+ - Jobs now have a path/url method
0.0.2
- Give credit to delayed_job
- Change description
View
2  README.rdoc
@@ -32,7 +32,7 @@ By creating a UrlJob using the following:
uj = UrlJob::Job.from_object(Redirector.new("http://frison.ca"))
And visiting:
- http://localhost:3000/uj/#{uj.token}
+ http://localhost:3000/uj/#{uj.token} or http://localhost:3000/uj/#{uj.path} or #{uj.url} (assuming default_url_options[:host] is setup for ActionMailer)
The result will be deserializing the Redirector job, and calling it's perform method.
The perform method must return an object that responds to either: 'redirect_to' or 'render', and the corresponding action will occur. The perform method will be passed in a dictionary with the following keys:
View
4 config/routes.rb
@@ -1,3 +1,3 @@
Rails.application.routes.draw do |map|
- match '/uj/:token', :action => 'perform', :controller => "UrlJob/UrlJob"
-end
+ match '/uj/:token', :action => 'perform', :controller => "UrlJob/UrlJob", :as => 'url_job'
+end
View
15 lib/url_job/job.rb
@@ -2,6 +2,8 @@ module UrlJob
require 'uniquify'
class Job < ActiveRecord::Base
+ include ActionController::UrlWriter
+
set_table_name :url_jobs
uniquify :token do
@@ -20,6 +22,18 @@ def from_object(object, &block)
end
end
+ def path
+ url_job_path(:token => self.token)
+ end
+
+ def url
+ url_job_url(:token => self.token, :host => host)
+ end
+
+ def host
+ ActionMailer::Base.default_url_options[:host]
+ end
+
def limit_reached?
return false if no_limit?
action_count >= action_limit
@@ -49,6 +63,5 @@ def payload_object
raise DeserializationError,
"UrlJob failed to load: #{e.message}. Handler: #{handler.inspect}"
end
-
end
end
View
2  lib/url_job/version.rb
@@ -1,3 +1,3 @@
module UrlJob
- VERSION = "0.0.2".freeze
+ VERSION = "0.0.3".freeze
end

No commit comments for this range

Something went wrong with that request. Please try again.