Add moderated_fields_for method

master
Guillaume DOTT 2013-11-28 11:07:19 +01:00
parent 9c24f2fc1b
commit 1752c5a843
2 changed files with 9 additions and 0 deletions

View File

@ -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)

View File

@ -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)