Skip to content

Instantly share code, notes, and snippets.

@xHire
Created June 28, 2009 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xHire/137289 to your computer and use it in GitHub Desktop.
Save xHire/137289 to your computer and use it in GitHub Desktop.
diff --git a/lib/activerecord-tableless.rb b/lib/activerecord-tableless.rb
index 83598c8..f865fed 100644
--- a/lib/activerecord-tableless.rb
+++ b/lib/activerecord-tableless.rb
@@ -16,8 +16,10 @@ module ActiveRecord
# has_no_table
#
# column :name, :string
- # column :email, :string
- # column :message, :string
+ #
+ # # or
+ #
+ # addcol :string, :email, :message
#
# end
#
@@ -69,6 +71,13 @@ module ActiveRecord
def column(name, sql_type = nil, default = nil, null = true)
tableless_options[:columns] << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
end
+
+ # Register a set of new columns
+ def addcol type, *args
+ args.each do |col|
+ column col, type
+ end
+ end
%w(find create destroy).each do |m|
eval %{
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment