Sha256: 2efbc4b54fa44d32e75ef6c61ab7dee2d61430b4172f3d82068a99e8f01ea958

Contents?: true

Size: 702 Bytes

Versions: 4

Compression:

Stored size: 702 Bytes

Contents

module MongoModel
  module AttributeMethods
    module Protected
      extend ActiveSupport::Concern
      
      include ActiveModel::MassAssignmentSecurity

      module ClassMethods
        def property(name, *args, &block)#:nodoc:
          property = super(name, *args, &block)

          attr_protected(name) if property.options[:protected]
          attr_accessible(name) if property.options[:accessible]
        
          property
        end
      end
    
      def assign_attributes(attrs, options={})
        if options[:without_protection]
          super
        else
          super(sanitize_for_mass_assignment(attrs, options[:as] || :default))
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mongomodel-0.5.5 lib/mongomodel/concerns/attribute_methods/protected.rb
mongomodel-0.5.4 lib/mongomodel/concerns/attribute_methods/protected.rb
mongomodel-0.5.3 lib/mongomodel/concerns/attribute_methods/protected.rb
mongomodel-0.5.2 lib/mongomodel/concerns/attribute_methods/protected.rb