lib/rom/sql/schema/index_dsl.rb in rom-sql-3.1.0 vs lib/rom/sql/schema/index_dsl.rb in rom-sql-3.2.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
require 'set'
module ROM
module SQL
class Schema < ROM::Schema
@@ -17,20 +19,21 @@
@registry = []
instance_exec(&block)
end
+ ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true)
# @api public
def index(*attributes, **options)
registry << [attributes, options]
end
# @api private
def call(schema_name, attrs)
attributes = attrs.map do |attr|
- attr_class.new(attr[:type], attr[:options] || {}).meta(source: schema_name)
+ attr_class.new(attr[:type], **(attr[:options] || {})).meta(source: schema_name)
end
registry.map { |attr_names, options|
build_index(attributes, attr_names, options)
}.to_set
@@ -42,10 +45,10 @@
def build_index(attributes, attr_names, options)
index_attributes = attr_names.map do |name|
attributes.find { |a| a.name == name }.unwrap
end
- Index.new(index_attributes, options)
+ Index.new(index_attributes, **options)
end
end
end
end
end