Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongoid_extended_dirty_trackable

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoid_extended_dirty_trackable

  • 0.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Build Status

Mongoid::ExtendedDirtyTrackable

A Mongoid Extension that gives you the ability to track changes to embedded and related documents through a parent.

It was born from a need in a production app I work on from which it was extracted. If you'd like a pretty detailed run down of what exactly the code is doing you can find it on my blog.

I don't consider this Gem production ready. Mostly because I ran into some issues when writing the specs after Gemifying the original Concern. None of these problems exist in my production app so I'm lead to believe they are the result of the hack job I did setting up and tearing down mongo for the tests. I plan on working these issues out in the near future and if you'd like to know more check out my blog post that covers them.

Installation

Add this line to your application's Gemfile:

gem 'mongoid_extended_dirty_trackable'

And then execute:

$ bundle

Or install it yourself with:

$ gem install mongoid_extended_dirty_trackable

Usage

I tried to make the specs work as documentation but for those of you averse to reading them I'll make it easy for you.

class Account
  include Mongoid::Document
  include Mongoid::ExtendedDirtyTrackable

  field :name

  embeds_one :address
  embeds_many :invoices
  has_many :offices
end

account = Account.create(name: "Prestige Worldwide")
account.name = "Umbrella Corp"
account.changed?                             #=> true
account.changes["name"]                      #=> ["Prestige Worldwide", "Umbrella Corp"]

account.create_address(zipcode: "90210")
account.address.zipcode = "1000 AS"
account.changed?                             #=> true
account.changes["zipcode"]                   #=> ["90210", "1000 AS"]

account.invoices.create(total: 420.00)
account.invoices.first.total = 69.69
account.changed?                             #=> true
account.changes["total"]                     #=> [420.00, 69.69]

office = account.offices.create(number: 666)
office.number = 5446

account.changed?                             #=> true
account.changes["number"]                    #=> [666, 5446]

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bin/console for an interactive prompt that will allow you to experiment.

Contributing

All pull requests are met with open arms and gratitude.

Check the TODO file or the Github Issue tracker for suggestions on where to begin.

Please be sure your pull request includes descriptive commit messages and tests that cover your feature, change, or bug.

  1. Fork it ( https://github.com/graves/mongoid_extended_dirty_trackable/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Similar Projects

versative/mongoid_relations_dirty_tracking - This is a little more full featured and much more in the direction I plan on taking but I feel like it can be done in a more simple manner with less code.

millisami/gist:721466 - The code in this Gist no longer works or maybe it never did but it served as the inspiration for my Gem. Thanks millisami!

FAQs

Package last updated on 26 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc