lib/torque/postgresql/adapter/schema_definitions.rb in torque-postgresql-1.1.8 vs lib/torque/postgresql/adapter/schema_definitions.rb in torque-postgresql-2.0.0
- old
+ new
@@ -5,21 +5,19 @@
# Creates a column with an interval type, allowing span of times and
# dates to be stored without having to store a seconds-based integer
# or any sort of other approach
def interval(*args, **options)
- args.each { |name| column(name, :interval, options) }
+ args.each { |name| column(name, :interval, **options) }
end
# Creates a column with an enum type, needing to specify the subtype,
# which is basically the name of the type defined prior creating the
# column
def enum(*args, **options)
- args.each do |name|
- type = options.fetch(:subtype, name)
- column(name, type, options)
- end
+ subtype = options.delete(:subtype)
+ args.each { |name| column(name, (subtype || name), **options) }
end
# Creates a column with an enum array type, needing to specify the
# subtype, which is basically the name of the type defined prior
# creating the column
@@ -32,26 +30,14 @@
module TableDefinition
include ColumnMethods
attr_reader :inherits
- def initialize(name, *_, **options)
- old_args = []
- old_args << options.delete(:temporary) || false
- old_args << options.delete(:options)
- old_args << options.delete(:as)
- comment = options.delete(:comment)
+ def initialize(*args, **options)
+ super
- super(name, *old_args, comment: comment)
-
- if options.key?(:inherits)
- @inherits = Array[options.delete(:inherits)].flatten.compact
- @inherited_id = !(options.key?(:primary_key) || options.key?(:id))
- end
- end
-
- def inherited_id?
- @inherited_id
+ @inherits = Array.wrap(options.delete(:inherits)).flatten.compact \
+ if options.key?(:inherits)
end
end
ActiveRecord::ConnectionAdapters::PostgreSQL::Table.include ColumnMethods
ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition.include TableDefinition