Dry SQL plugin
Plugin details
Documentation
ruby script/plugin install http://drysql.rubyforge.org/svn/
Using DrySQL
1. Download from RubyForge or use RubyGems: gem install drysql
2. Call require_gem 'drysql' somewhere in your application code such that it will get processed before you attempt to instantiate a model class (i.e. a subclass of ActiveRecord::Base)
3. That's all!
DrySQL is an extension to ActiveRecord, and is compatible with any plug-ins that ActiveRecord is compatible with. You don't need to "do" anything to use DrySQL other than require the gem in your application code. DrySQL simply removes the need for the remaining bits of Object-Relational Mapping redundancy, namely the definition of associations, validations, and keys.
Your class definition without DrySQL
class Employee < ActiveRecord::Base set_table_name "EMP123" set_primary_key "EMP_REF_ID" belongs_to :department, :foreign_key=>'DEP_NAME' has_many :projects, :foreign_key=>'PROJECT_NAME' has_one :location has_many :whatevers, :through=>projects validates_length_of :NAME, :allow_nil=>true, :maximum=>20 validates_numericality_of :EMP_REF_ID, :allow_nil=>false, only_integer=>true end
Your class definition with DrySQL
class Employee < ActiveRecord::Base set_table_name "EMP123" end
The only Object-Relational Mapping burden that the programmer has to bear is the class => table_name mapping:
1. Your table name must be compatible with the ActiveRecord naming conventions
OR
2. You must define a class for your table and call set_table_name inside it.
That's all!
Primary Keys, Foreign Keys, Unique Keys, Column Names, Column Constraints, Table Constraints, Referential Constraints...it's all there in your database's information schema. DrySQL gathers this information through extension APIs on the standard ActiveRecord DB adapters, so that you don't need to re-define any of it in your application code.
Further Documentation
There is currently no advanced documentation for this plugin.
New documentationEdit plugin | (0 older versions) | Last edited by: hardway, 9 months ago

