Skip to content

Commit

Permalink
Cleared deprecation warning: "class_inheritable_attribute is deprecat…
Browse files Browse the repository at this point in the history
…ed, please use class_attribute method instead"

Signed-off-by: Marc Love <marcslove@gmail.com>
  • Loading branch information
marclove committed Apr 22, 2011
1 parent 04b4ba9 commit bebdeca
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
8 changes: 6 additions & 2 deletions lib/mongo_mapper/plugins/accessible.rb
Expand Up @@ -3,18 +3,22 @@ module Plugins
module Accessible
extend ActiveSupport::Concern

included do
class_attribute :_attr_accessible
end

module ClassMethods
def attr_accessible(*attrs)
raise AccessibleOrProtected.new(name) if try(:protected_attributes?)
self.write_inheritable_attribute(:attr_accessible, Set.new(attrs) + (accessible_attributes || []))
self._attr_accessible = Set.new(attrs) + (accessible_attributes || [])
end

def accessible_attributes?
!accessible_attributes.nil?
end

def accessible_attributes
self.read_inheritable_attribute(:attr_accessible)
self._attr_accessible
end
end

Expand Down
8 changes: 6 additions & 2 deletions lib/mongo_mapper/plugins/protected.rb
Expand Up @@ -6,14 +6,18 @@ module Plugins
module Protected
extend ActiveSupport::Concern

included do
class_attribute :_attr_protected
end

module ClassMethods
def attr_protected(*attrs)
raise AccessibleOrProtected.new(name) if try(:accessible_attributes?)
self.write_inheritable_attribute(:attr_protected, Set.new(attrs) + (protected_attributes || []))
self._attr_protected = Set.new(attrs) + (protected_attributes || [])
end

def protected_attributes
self.read_inheritable_attribute(:attr_protected)
self._attr_protected
end

def protected_attributes?
Expand Down
6 changes: 5 additions & 1 deletion lib/mongo_mapper/plugins/scopes.rb
Expand Up @@ -4,6 +4,10 @@ module Plugins
module Scopes
extend ActiveSupport::Concern

included do
class_attribute :_scopes
end

module ClassMethods
def scope(name, scope_options={})
scopes[name] = lambda do |*args|
Expand All @@ -15,7 +19,7 @@ def scope(name, scope_options={})
end

def scopes
read_inheritable_attribute(:scopes) || write_inheritable_attribute(:scopes, {})
self._scopes || self._scopes = {}
end
end
end
Expand Down

0 comments on commit bebdeca

Please sign in to comment.