GithubHelp home page GithubHelp logo

mongoid_signature's Introduction

Sign mongoid documents to prevent duplicates.

Requirements

  • mongoid (>= 2.0.0.rc7)

Install

To install mongoid_signature, simply add it to your Gemfile:

gem 'mongoid_signature'

In order to get the latest development version of mongoid_signature:

gem 'mongoid_signature', :git => 'https://github.com/connectedbits/mongoid_signature.git'

And then:

bundle install

Usage

Add the include Mongoid::Signature in the model:

class User include Mongoid::Document include Mongoid::Signature

field :name field :email

references_many :posts references_many :comments

sign_document :include => [:name] end

class Post include Mongoid::Document include Mongoid::Timestamps include Mongoid::Signature

field :title field :body field :published, :type => Boolean, :default => false

referenced_in :users embeds_many :comments

sign_document :include => [:user, :title, :body] end class Comment include Mongoid::Document include Mongoid::Timestamps include Mongoid::Signature

field :body

embedded_in :post referenced_in :user

sign_document :include => [:user, :body] end

Signing

This will add a signature field to your document and provide additional signature_string and sign! methods:

>> @user = User.new(:name => ‘Eric’) => #<User _id: 4d66a345bf354104bd000002, name: “Eric”, signature: nil, email: nil> >> @user.sign! => “535d6fcc4483b2d02167d2d4bc05fdff5e34f6538ac6fa897c63b11d8417e815”

Known issues

See github.com//mongoid_signature/issues

Repository

See github.com/connectedbits/mongoid_signature and feel free to fork it!

Contributors

See a list of all contributors at github.com/connected/mongoid_signature/contributors. Thanks a lot everyone!

Copyright © 2011 Connected Bits, LLC. See LICENSE for details.

mongoid_signature's People

Contributors

carlson avatar davemitchell avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.