jmchambers / mm_no_empties

MongoMapper plugin that prevents any fields responding to empty? from being persisted if empty (nils are also excluded as per standard MM behaviour)

Home Page:https://github.com/jmchambers/mm_no_empties

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mm_no_empties

Models that use this plugin do not persist empty Arrays, Hashes or Sets. Nil values are also excluded as per standard MM behaviour.

Requirements

  • Ruby 1.9
  • MongoMapper 0.10.1 or greater

Installation

Add this to your Gemfile if using Bundler: gem 'mm_no_empties'

Or install the gem from the command line: gem install mm_no_empties

Usage

Use the MongoMapper plugin method to add MmNoEmpties to your model, for example:

class Group
  include MongoMapper::Document
  plugin  MmNoEmpties
  
  many :people, :class_name => 'Person'
  
  key  :names,  Array
  key  :counts, Hash
  key  :tags,   Set
end

Copyright (c) 2011 PeepAll Ltd, released under the MIT license

About

MongoMapper plugin that prevents any fields responding to empty? from being persisted if empty (nils are also excluded as per standard MM behaviour)

https://github.com/jmchambers/mm_no_empties

License:MIT License


Languages

Language:Ruby 100.0%