Class: ROM::SQL::Schema::IndexDSL
- Inherits:
-
Object
- Object
- ROM::SQL::Schema::IndexDSL
- Extended by:
- Initializer
- Defined in:
- lib/rom/sql/schema/index_dsl.rb
Instance Attribute Summary collapse
- #registry ⇒ Object readonly
Instance Method Summary collapse
- #call(schema_name, attrs) ⇒ Object private
- #index(*attributes, **options) ⇒ Object
-
#initialize(&block) ⇒ IndexDSL
constructor
private
A new instance of IndexDSL.
Constructor Details
#initialize(&block) ⇒ IndexDSL
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of IndexDSL.
17 18 19 20 21 22 23 |
# File 'lib/rom/sql/schema/index_dsl.rb', line 17 def initialize(*, &block) super @registry = [] instance_exec(&block) end |
Instance Attribute Details
#registry ⇒ Object (readonly)
14 15 16 |
# File 'lib/rom/sql/schema/index_dsl.rb', line 14 def registry @registry end |
Instance Method Details
#call(schema_name, attrs) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 35 36 37 38 39 40 |
# File 'lib/rom/sql/schema/index_dsl.rb', line 32 def call(schema_name, attrs) attributes = attrs.map do |attr| attr_class.new(attr[:type], **(attr[:options] || {})).(source: schema_name) end registry.map { |attr_names, | build_index(attributes, attr_names, ) }.to_set end |
#index(*attributes, **options) ⇒ Object
27 28 29 |
# File 'lib/rom/sql/schema/index_dsl.rb', line 27 def index(*attributes, **) registry << [attributes, ] end |