Module: MongoMapper::Plugins::Protected::ClassMethods

Defined in:
lib/mongo_mapper/plugins/protected.rb

Instance Method Summary collapse

Instance Method Details

#attr_protected(*attrs) ⇒ Object



8
9
10
11
# File 'lib/mongo_mapper/plugins/protected.rb', line 8

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

#key(*args) ⇒ Object



21
22
23
24
25
# File 'lib/mongo_mapper/plugins/protected.rb', line 21

def key(*args)
  key = super
  attr_protected key.name.to_sym if key.options[:protected]
  key
end

#protected_attributesObject



13
14
15
# File 'lib/mongo_mapper/plugins/protected.rb', line 13

def protected_attributes
  self.read_inheritable_attribute(:attr_protected)
end

#protected_attributes?Boolean

Returns:



17
18
19
# File 'lib/mongo_mapper/plugins/protected.rb', line 17

def protected_attributes?
  !protected_attributes.nil?
end