aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/post_redirect.rb33
1 files changed, 16 insertions, 17 deletions
diff --git a/app/models/post_redirect.rb b/app/models/post_redirect.rb
index 770f06a02..fbf52059b 100644
--- a/app/models/post_redirect.rb
+++ b/app/models/post_redirect.rb
@@ -33,7 +33,6 @@ class PostRedirect < ActiveRecord::Base
after_initialize :generate_token
-
# Makes a random token, suitable for using in URLs e.g confirmation
# messages.
def self.generate_random_token
@@ -47,52 +46,52 @@ class PostRedirect < ActiveRecord::Base
# apart from in the place that it redirects to.
post_redirects = PostRedirect.find_by_sql("select * from post_redirects order by id desc limit 1")
post_redirects.size.should == 1
- return post_redirects[0]
+ post_redirects[0]
end
# Called from cron job delete-old-things
def self.delete_old_post_redirects
- PostRedirect.delete_all "updated_at < (now() - interval '2 months')"
+ PostRedirect.delete_all("updated_at < (now() - interval '2 months')")
end
# We store YAML version of POST parameters in the database
def post_params=(params)
self.post_params_yaml = params.to_yaml
end
+
def post_params
- if self.post_params_yaml.nil?
- return {}
- end
- YAML.load(self.post_params_yaml)
+ return {} if post_params_yaml.nil?
+ YAML.load(post_params_yaml)
end
# We store YAML version of textual "reason for redirect" parameters
def reason_params=(reason_params)
self.reason_params_yaml = reason_params.to_yaml
end
+
def reason_params
- YAML.load(self.reason_params_yaml)
+ YAML.load(reason_params_yaml)
end
# Extract just local path part, without domain or #
def local_part_uri
- self.uri.match(/^http:\/\/.+?(\/[^#]+)/)
- return $1
+ uri.match(/^http:\/\/.+?(\/[^#]+)/)
+ $1
end
private
def generate_token
- # The token is used to return you to what you are doing after the login form.
- if not self.token
+ # The token is used to return you to what you are doing after the login
+ # form.
+ unless token
self.token = PostRedirect.generate_random_token
end
- # There is a separate token to use in the URL if we send a confirmation email.
- if not self.email_token
+
+ # There is a separate token to use in the URL if we send a confirmation
+ # email.
+ unless email_token
self.email_token = PostRedirect.generate_random_token
end
end
end
-
-
-