Module Sequel::Model::DatasetMethods
In: lib/sequel_model/dataset_methods.rb

Dataset methods are methods that the model class extends its dataset with in the call to set_dataset.

Methods

destroy   to_hash  

Public Instance methods

Destroy each row in the dataset by instantiating it and then calling destroy on the resulting model object. This isn‘t as fast as deleting the object, which does a single SQL call, but this runs any destroy hooks.

[Source]

    # File lib/sequel_model/dataset_methods.rb, line 8
 8:   def destroy
 9:     raise(Error, "No model associated with this dataset") unless @opts[:models]
10:     count = 0
11:     @db.transaction{all{|r| count += 1; r.destroy}}
12:     count
13:   end

This allows you to call to_hash without any arguments, which will result in a hash with the primary key value being the key and the model object being the value.

[Source]

    # File lib/sequel_model/dataset_methods.rb, line 18
18:   def to_hash(key_column=nil, value_column=nil)
19:     if key_column
20:       super
21:     else
22:       raise(Sequel::Error, "No primary key for model") unless pk = @opts[:models][nil].primary_key
23:       super(pk, value_column) 
24:     end
25:   end

[Validate]