-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
url data can be reinitialized #202
base: master
Are you sure you want to change the base?
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# encoding: UTF-8 | ||
require "stringex/acts_as_url/adapter" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing magic comment # frozen_string_literal: true. |
||
require 'stringex/acts_as_url/adapter' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
|
||
module Stringex | ||
module ActsAsUrl # :nodoc: | ||
|
@@ -61,9 +61,7 @@ class << self | |
|
||
define_method :acts_as_url_configuration do | ||
klass = self.class | ||
while klass.acts_as_url_configuration.nil? | ||
klass = klass.superclass | ||
end | ||
klass = klass.superclass while klass.acts_as_url_configuration.nil? | ||
klass.acts_as_url_configuration | ||
end | ||
end | ||
|
@@ -74,7 +72,6 @@ class << self | |
acts_as_url_configuration.adapter.create_callbacks! self | ||
end | ||
|
||
|
||
# Some ORMs function as mixins not base classes and need to have a hook to reinclude | ||
# and re-extend ActsAsUrl methods | ||
def included(base = nil, &block) | ||
|
@@ -96,6 +93,13 @@ def included(base = nil, &block) | |
def initialize_urls | ||
acts_as_url_configuration.adapter.initialize_urls! self | ||
end | ||
|
||
# Renitialize the url fields for the all records. Designed for people who | ||
# want to update <tt>acts_as_url</tt> support once there's already | ||
# development/production data they'd like to keep around. | ||
def reinitialize_urls | ||
acts_as_url_configuration.adapter.reinitialize_urls! self | ||
end | ||
end | ||
|
||
module ActsAsUrlInstanceMethods | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing magic comment # frozen_string_literal: true.