lib/mongo_mapper/plugins/accessible.rb in mongo_mapper-0.11.1 vs lib/mongo_mapper/plugins/accessible.rb in mongo_mapper-0.11.2
- old
+ new
@@ -2,18 +2,26 @@
module Plugins
module Accessible
extend ActiveSupport::Concern
included do
- class_attribute :accessible_attributes
+ class_attribute :_accessible_attributes
end
module ClassMethods
def attr_accessible(*attrs)
raise AccessibleOrProtected.new(name) if try(:protected_attributes?)
- self.accessible_attributes = Set.new(attrs) + (accessible_attributes || [])
+ self._accessible_attributes = Set.new(attrs) + (_accessible_attributes || [])
end
+
+ def accessible_attributes(*)
+ _accessible_attributes
+ end
+
+ def accessible_attributes?
+ _accessible_attributes?
+ end
end
def attributes=(attrs={})
super(filter_inaccessible_attrs(attrs))
end
@@ -22,9 +30,17 @@
super(filter_inaccessible_attrs(attrs))
end
def update_attributes!(attrs={})
super(filter_inaccessible_attrs(attrs))
+ end
+
+ def accessible_attributes(*args)
+ self.class.accessible_attributes(*args)
+ end
+
+ def accessible_attributes?
+ self.class.accessible_attributes?
end
protected
def filter_inaccessible_attrs(attrs)
return attrs if !accessible_attributes? || attrs.blank?
\ No newline at end of file