Method: ROM::Relation::ClassInterface#dataset

Defined in:
lib/rom/relation/class_interface.rb

#dataset(&block) ⇒ Object

Set or get custom dataset block

This block will be evaluated when a relation is instantiated and registered in a relation registry.

Examples:

class Users < ROM::Relation[:memory]
  dataset { sort_by(:id) }
end


62
63
64
65
66
67
68
# File 'lib/rom/relation/class_interface.rb', line 62

def dataset(&block)
  if defined?(@dataset)
    @dataset
  else
    @dataset = block || DEFAULT_DATASET_PROC
  end
end