@@ -194,18 +194,22 @@ class Command
194194
195195 # @!attribute [r] relation
196196 # @return [Relation] Command's relation
197- param :relation
197+ param :dataset
198198
199199 CommandType = Types ::Strict ::Symbol . enum ( :create , :update , :delete )
200200 Result = Types ::Strict ::Symbol . enum ( :one , :many )
201201
202+ # @!attribute [r] schema
203+ # @return [Schema] Relation's schema
204+ option :schema , optional : true
205+
202206 # @!attribute [r] type
203207 # @return [Symbol] The command type, one of :create, :update or :delete
204208 option :type , type : CommandType , optional : true
205209
206210 # @!attribute [r] source
207- # @return [Relation ] The source relation
208- option :source , default : -> { relation }
211+ # @return [Dataset ] The source dataset
212+ option :source , default : -> { dataset }
209213
210214 # @!attribute [r] result
211215 # @return [Symbol] Result type, either :one or :many
@@ -227,26 +231,18 @@ class Command
227231 # @return [Array<Hash>] An array with after hooks configuration
228232 option :after , Types ::Coercible ::Array , reader : false , default : -> { self . class . after }
229233
230- input Hash
231- result :many
232-
233- # Return name of this command's relation
234- #
235- # @return [ROM::Relation::Name]
236- #
234+ # !@attribute :name
235+ # @return [ROM::Relation::Name] Return name of this command's relation
237236 # @api public
238- def name
239- relation . name
240- end
237+ option :name , optional : true
241238
242- # Return gateway of this command's relation
243- #
244- # @return [Symbol]
245- #
239+ # !@attribute :gateway
240+ # @return [Symbol] Return gateway of this command's relation
246241 # @api public
247- def gateway
248- relation . gateway
249- end
242+ option :gateway , optional : true
243+
244+ input Hash
245+ result :many
250246
251247 # Execute the command
252248 #
@@ -314,7 +310,7 @@ def curry(*args)
314310 if curry_args . empty? && args . first . is_a? ( Graph ::InputEvaluator )
315311 Lazy [ self ] . new ( self , *args )
316312 else
317- self . class . build ( relation , **options , curry_args : args )
313+ self . class . build ( dataset , **options , curry_args : args )
318314 end
319315 end
320316
@@ -346,7 +342,7 @@ def curried?
346342 #
347343 # @api public
348344 def before ( *hooks )
349- self . class . new ( relation , **options , before : before_hooks + hooks )
345+ self . class . new ( dataset , **options , before : before_hooks + hooks )
350346 end
351347
352348 # Return a new command with appended after hooks
@@ -357,7 +353,7 @@ def before(*hooks)
357353 #
358354 # @api public
359355 def after ( *hooks )
360- self . class . new ( relation , **options , after : after_hooks + hooks )
356+ self . class . new ( dataset , **options , after : after_hooks + hooks )
361357 end
362358
363359 # List of before hooks
@@ -378,15 +374,15 @@ def after_hooks
378374 options [ :after ]
379375 end
380376
381- # Return a new command with other source relation
377+ # Return a new command with other source dataset
382378 #
383- # This can be used to restrict command with a specific relation
379+ # This can be used to restrict command with a specific dataset
384380 #
385381 # @return [Command]
386382 #
387383 # @api public
388- def new ( new_relation )
389- self . class . build ( new_relation , **options , source : relation )
384+ def new ( new_dataset )
385+ self . class . build ( new_dataset , **options , source : dataset )
390386 end
391387
392388 # Check if this command has any hooks
@@ -432,22 +428,13 @@ def many?
432428 result . equal? ( :many )
433429 end
434430
435- # Check if this command is restrictible through relation
436- #
437- # @return [TrueClass,FalseClass]
438- #
439- # @api private
440- def restrictible?
441- self . class . restrictable . equal? ( true )
442- end
443-
444431 # Yields tuples for insertion or return an enumerator
445432 #
446433 # @api private
447434 def map_input_tuples ( tuples , &mapper )
448435 return enum_for ( :with_input_tuples , tuples ) unless mapper
449436
450- if tuples . respond_to? :merge
437+ if tuples . respond_to? ( :merge )
451438 mapper [ tuples ]
452439 else
453440 tuples . map ( &mapper )
0 commit comments