@@ -144,7 +144,9 @@ class Relation
144
144
# @!attribute [r] name
145
145
# @return [Object] The relation name
146
146
# @api public
147
- option :name , default : -> { self . class . schema ? self . class . schema . name : self . class . default_name }
147
+ option :name , default : lambda {
148
+ self . class . schema ? self . class . schema . name : self . class . default_name
149
+ }
148
150
149
151
# @!attribute [r] input_schema
150
152
# @return [Object#[]] tuple processing function, uses schema or defaults to Hash[]
@@ -191,12 +193,14 @@ class Relation
191
193
#
192
194
# @example accessing canonical attribute
193
195
# users[:id]
194
- # # => #<ROM::SQL::Attribute[Integer] primary_key=true name=:id source=ROM::Relation::Name(users)>
196
+ # # => #<ROM::SQL::Attribute[Integer] primary_key=true
197
+ # # name=:id source=ROM::Relation::Name(users)>
195
198
#
196
199
# @example accessing joined attribute
197
200
# tasks_with_users = tasks.join(users).select_append(tasks[:title])
198
201
# tasks_with_users[:title, :tasks]
199
- # # => #<ROM::SQL::Attribute[String] primary_key=false name=:title source=ROM::Relation::Name(tasks)>
202
+ # # => #<ROM::SQL::Attribute[String] primary_key=false
203
+ # # name=:title source=ROM::Relation::Name(tasks)>
200
204
#
201
205
# @return [Attribute]
202
206
#
@@ -214,11 +218,11 @@ def [](name)
214
218
# @return [Enumerator] if block is not provided
215
219
#
216
220
# @api public
217
- def each
221
+ def each ( & )
218
222
return to_enum unless block_given?
219
223
220
224
if auto_map?
221
- mapper . ( dataset . map { |tuple | output_schema [ tuple ] } ) . each { | struct | yield ( struct ) }
225
+ mapper . ( dataset . map { |tuple | output_schema [ tuple ] } ) . each ( & )
222
226
else
223
227
dataset . each { |tuple | yield ( output_schema [ tuple ] ) }
224
228
end
@@ -420,7 +424,7 @@ def new(dataset, **new_opts)
420
424
if new_opts . empty?
421
425
options
422
426
elsif new_opts . key? ( :schema )
423
- options . merge ( new_opts ) . reject { |k , _ | k == : input_schema || k == : output_schema }
427
+ options . merge ( new_opts ) . reject { |k , _ | %i[ input_schema output_schema ] . include? ( k ) }
424
428
else
425
429
options . merge ( new_opts )
426
430
end
@@ -476,7 +480,8 @@ def attr_ast
476
480
477
481
# @api private
478
482
def meta_ast
479
- meta = self . meta . merge ( dataset : name . dataset , alias : name . aliaz , struct_namespace : options [ :struct_namespace ] )
483
+ meta = self . meta . merge ( dataset : name . dataset , alias : name . aliaz ,
484
+ struct_namespace : options [ :struct_namespace ] )
480
485
meta [ :model ] = false unless auto_struct? || meta [ :model ]
481
486
meta
482
487
end
0 commit comments