# Sets default properties at creation time
def default_properties
- default_props = Rails.configuration.Collections.DefaultProperties
+ default_props = Rails.configuration.Collections.DefaultProperties.with_indifferent_access
if default_props.empty?
return
end
end
def protected_default_properties_updates
- if Rails.configuration.Collections.DefaultProperties.empty? || !properties_changed? || current_user.is_admin
+ default_properties = Rails.configuration.Collections.DefaultProperties.with_indifferent_access
+ if default_properties.empty? || !properties_changed? || current_user.is_admin
return true
end
- protected_props = Rails.configuration.Collections.DefaultProperties.keys.select do |p|
+ protected_props = default_properties.keys.select do |p|
Rails.configuration.Collections.DefaultProperties[p]['protected']
end
# Pre-existent protected properties can't be updated
invalid_updates = properties_was.keys.select{|p| properties_was[p] != properties[p]} & protected_props
if !invalid_updates.empty?
- errors.add(:properties, "protected properties cannot be updated: #{invalid_updates.join(', ')}")
- raise PermissionDeniedError
+ raise PermissionDeniedError.new("protected properties cannot be updated: #{invalid_updates.join(', ')}")
end
true
end