Class: ROM::Components::Dataset

Inherits:
Core
  • Object
show all
Defined in:
lib/rom/components/dataset.rb,
lib/rom/compat/components.rb

Instance Method Summary collapse

Instance Method Details

#adapterObject



31
32
33
# File 'lib/rom/components/dataset.rb', line 31

def adapter
  config.adapter
end

#blocksObject

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.



21
22
23
# File 'lib/rom/components/dataset.rb', line 21

def blocks
  [*dataset_components.map(&:block), block].compact
end

#buildObject



10
11
12
13
14
15
16
17
18
# File 'lib/rom/components/dataset.rb', line 10

def build
  if gateway?
    blocks.reduce(gateway.dataset(id)) { |ds, blk| evaluate_block(ds, blk) }
  elsif block
    schema ? block.(schema) : block.()
  else
    EMPTY_ARRAY
  end
end

#evaluate_block(ds, block) ⇒ 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.



26
27
28
# File 'lib/rom/components/dataset.rb', line 26

def evaluate_block(ds, block)
  ds.instance_exec(schema, &block)
end

#relation_idObject



36
37
38
# File 'lib/rom/components/dataset.rb', line 36

def relation_id
  config.relation_id
end