diff --git a/app/models/concerns/wp_redirect.rb b/app/models/concerns/wp_redirect.rb new file mode 100644 index 0000000..e969638 --- /dev/null +++ b/app/models/concerns/wp_redirect.rb @@ -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