diff --git a/lib/the_moderator/model.rb b/lib/the_moderator/model.rb index 951bbe8..7f02d7b 100644 --- a/lib/the_moderator/model.rb +++ b/lib/the_moderator/model.rb @@ -23,6 +23,11 @@ module TheModerator false end + def moderated_fields_for(assoc) + moderations.map { |m| m.moderated_fields_for(assoc) } + .inject(&:|) + end + protected def moderation_data(*moderated_attributes) diff --git a/lib/the_moderator/moderation_model.rb b/lib/the_moderator/moderation_model.rb index 0c28275..ec67746 100644 --- a/lib/the_moderator/moderation_model.rb +++ b/lib/the_moderator/moderation_model.rb @@ -41,6 +41,10 @@ module TheModerator include_attribute?(attribute, data[:attributes]) end + def moderated_fields_for(assoc) + (data[:attributes][assoc].try(:keys) || []) - [:id] + end + private def include_attribute?(attribute, attr_data)