Sha256: 63a4714e040b644fa6b2acdf3e79b990fb257dc2160253ab45fe0c8d33f823da
Contents?: true
Size: 1.63 KB
Versions: 3
Compression:
Stored size: 1.63 KB
Contents
= machinist_callbacks Some record construction rules cannot be expressed with a {machinist}[http://github.com/notahat/machinist] blueprint, for instance: * Creating a record with a has_many association already filled in. * Creating a record with interdependencies between associated object, such as having to belong to the same container. * Needing to process a {delayed_job}[http://github.com/tobi/delayed_job] queue after record construction. This gem provides <tt>before_make</tt> and <tt>after_make</tt> callbacks for machinist blueprints, enabling more freedom in your construction rules. == Example Movie.blueprint do title year 2001 before_make do self.producer = Producer.make(:name => director.name) end end Director.blueprint do name after_make do movies << Movie.make end end == Does it work with make_unsaved? Yes. Machinist is built in a way that every <tt>make</tt> in your callback implicitely becomes a <tt>make_unsaved</tt> when an object graph is created with <tt>make_unsaved</tt>. == Installation You can install the gem with sudo gem install machinist_callbacks In Rails 2, add the following to your <tt>environment.rb</tt>: config.gem 'machinist_callbacks' In Rails 3, add the following to your <tt>Gemfile</tt>: gem 'machinist_callbacks' == Rails 3 compatibility We cannot guarantee Rails 3 compatibility at this point, but we will upgrade the gem when Rails 3 is released. === Credits Henning Koch {makandra.com}[http://makandra.com/] {gem-session.com}[http://gem-session.com/]
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
machinist_callbacks-0.2.0 | README.rdoc |
machinist_callbacks-0.1.3 | README.rdoc |
machinist_callbacks-0.1.2 | README.rdoc |