-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from wponrails/feature/redirects
Feature/redirects
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module WpRedirect | ||
extend ActiveSupport::Concern | ||
|
||
def update_wp_redirect_attributes(json) | ||
return unless json.is_a?(Hash) | ||
|
||
self.wp_id = json['id'] | ||
self.from = json['from'] | ||
self.to = json['to'] | ||
|
||
save! | ||
end | ||
|
||
# implements class methods | ||
module ClassMethods | ||
def mappable_wordpress_attributes | ||
%w( id from to ) | ||
end | ||
|
||
def wp_type | ||
to_s.demodulize.underscore.pluralize | ||
end | ||
end | ||
end |