Module: CouchRest::Model::PropertyProtection
- Extended by:
- ActiveSupport::Concern
- Included in:
- Base
- Defined in:
- lib/couchrest/model/property_protection.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #accessible_properties ⇒ Object
- #protected_properties ⇒ Object
-
#remove_protected_attributes(attributes) ⇒ Object
Return a new copy of the attributes hash with protected attributes removed.
Class Method Details
.included(base) ⇒ Object
31 32 33 |
# File 'lib/couchrest/model/property_protection.rb', line 31 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#accessible_properties ⇒ Object
50 51 52 |
# File 'lib/couchrest/model/property_protection.rb', line 50 def accessible_properties self.class.accessible_properties end |
#protected_properties ⇒ Object
54 55 56 |
# File 'lib/couchrest/model/property_protection.rb', line 54 def protected_properties self.class.protected_properties end |
#remove_protected_attributes(attributes) ⇒ Object
Return a new copy of the attributes hash with protected attributes removed.
60 61 62 63 64 65 66 67 |
# File 'lib/couchrest/model/property_protection.rb', line 60 def remove_protected_attributes(attributes) protected_names = protected_properties.map { |prop| prop.name } return attributes if protected_names.empty? or attributes.nil? attributes.reject do |property_name, property_value| protected_names.include?(property_name.to_s) end end |