lib/ridgepole/dsl_parser.rb in ridgepole-0.4.1 vs lib/ridgepole/dsl_parser.rb in ridgepole-0.4.2
- old
+ new
@@ -35,9 +35,25 @@
options = args.extract_options!
column_names = args
column_names.each {|name| column(name, column_type, options) }
end
end
+
+ def timestamps(*args)
+ options = { :null => false }.merge(args.extract_options!)
+ column(:created_at, :datetime, options.dup)
+ column(:updated_at, :datetime, options.dup)
+ end
+
+ def references(*args)
+ options = args.extract_options!
+ polymorphic = options.delete(:polymorphic)
+ args.each do |col|
+ column("#{col}_id", :integer, options.dup)
+ column("#{col}_type", :string, polymorphic.is_a?(Hash) ? polymorphic : options.dup) unless polymorphic.nil?
+ end
+ end
+ alias :belongs_to :references
end
attr_reader :__definition
def initialize(opts = {})