public
Description: ActiveRecord.create_or_update_by_natural_key
Homepage: http://www.pathf.com
Clone URL: git://github.com/sjain/natural_key.git
sjain (author)
Mon Jan 12 15:16:23 -0800 2009
commit  d3791a2251d57b965f6afed77c791240a3943884
tree    8f6facbeb46d1041f1f87a3ad540a73c08e5db32
parent  58df4f3d9920ff9c899df31dc3b555b8b735f280
README.rdoc

natural_key

DESCRIPTION:

This gem adds create_or_update functionality to ActiveRecord based on a user-defined natural-key.

FEATURES/PROBLEMS:

  • TODO

SYNOPSIS:

Define natural key for your model as follows:

  #
  # Table users(first_name varchar, last_name varchar, age integer, address string, salary integer)
  #
  class User < ActiveRecord::Base
    natural_key :first_name, :last_name
  end

With this in place, a method ‘create_or_update_by_natural_key’ can be used to invoke create/update.

  User.create_or_update_by_natural_key(:first_name => 'John', :last_name => "Smith", :age => 25, :address => "New York")

REQUIREMENTS:

  • TODO

INSTALL:

  gem install sjain-natural_key --source http://gems.github.com; rake gems:unpack GEM=sjain-natural_key

LICENSE:

(The MIT License)

Copyright © 2009 Pathfinder Associates, LLC.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.