# File lib/couchrest/mixins/attribute_protection.rb, line 37 def accessible_properties self.class.accessible_properties end
# File lib/couchrest/mixins/attribute_protection.rb, line 41 def protected_properties self.class.protected_properties end
# File lib/couchrest/mixins/attribute_protection.rb, line 45 def remove_protected_attributes(attributes) protected_names = properties_to_remove_from_mass_assignment.map { |prop| prop.name } return attributes if protected_names.empty? attributes.reject! do |property_name, property_value| protected_names.include?(property_name.to_s) end attributes || {} end
Attribute protection from mass assignment to CouchRest properties
Protected methods will be removed from
* new * update_attributes * upate_attributes_without_saving * attributes=
There are two modes of protection
1) Declare accessible poperties, assume all the rest are protected property :name, :accessible => true property :admin # this will be automatically protected 2) Declare protected properties, assume all the rest are accessible property :name # this will not be protected property :admin, :protected => true
Note: you cannot set both flags in a single class
# File lib/couchrest/mixins/attribute_protection.rb, line 23 def self.included(base) base.extend(ClassMethods) end