lib/mongomodel/concerns/attribute_methods/protected.rb in mongomodel-0.4.8 vs lib/mongomodel/concerns/attribute_methods/protected.rb in mongomodel-0.4.9
- old
+ new
@@ -1,28 +1,32 @@
module MongoModel
module AttributeMethods
module Protected
extend ActiveSupport::Concern
- include ActiveModel::MassAssignmentSecurity
+ if defined?(ActiveModel::MassAssignmentSecurity)
+ include ActiveModel::MassAssignmentSecurity
- module ClassMethods
- def property(name, *args, &block)#:nodoc:
- property = super(name, *args, &block)
+ module ClassMethods
+ def property(name, *args, &block)#:nodoc:
+ property = super(name, *args, &block)
- attr_protected(name) if property.options[:protected]
- attr_accessible(name) if property.options[:accessible]
+ attr_protected(name) if property.options[:protected]
+ attr_accessible(name) if property.options[:accessible]
- property
+ property
+ end
end
- end
- def assign_attributes(attrs, options={})
- if options[:without_protection]
- super
- else
- super(sanitize_for_mass_assignment(attrs, options[:as] || :default))
+ def assign_attributes(attrs, options={})
+ if options[:without_protection]
+ super
+ else
+ super(sanitize_for_mass_assignment(attrs, options[:as] || :default))
+ end
end
+ elsif defined?(ActiveModel::DeprecatedMassAssignmentSecurity)
+ include ActiveModel::DeprecatedMassAssignmentSecurity
end
end
end
end