From b37d5eff3a7cf5f698fabd62dc5ab42e664a0785 Mon Sep 17 00:00:00 2001 From: Sebastiaan de Geus Date: Tue, 7 Jul 2015 15:18:27 +0200 Subject: [PATCH] add wp_redirect concern --- app/models/concerns/wp_redirect.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 app/models/concerns/wp_redirect.rb diff --git a/app/models/concerns/wp_redirect.rb b/app/models/concerns/wp_redirect.rb new file mode 100644 index 0000000..db5edbe --- /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( name slug description count ) + end + + def wp_type + to_s.demodulize.underscore.pluralize + end + end +end