Class: ROM::Components::Dataset
- Inherits:
-
Core
- Object
- Core
- ROM::Components::Dataset
show all
- Defined in:
- lib/rom/components/dataset.rb,
lib/rom/compat/components.rb
Instance Attribute Summary
Attributes inherited from Core
#config, #gateway, #provider
Instance Method Summary
collapse
Methods inherited from Core
#abstract, #apply_external_plugins, #apply_plugins, #components, #gateway?, #gateway_plugins, #id, #inflector, inherited, #key, #local_components, #namespace, #notifications, #plugin_options, #plugins, #provider_plugins, #trigger, #type
extended
Instance Method Details
#adapter ⇒ Object
31
32
33
|
# File 'lib/rom/components/dataset.rb', line 31
def adapter
config.adapter
end
|
#blocks ⇒ 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.
21
22
23
|
# File 'lib/rom/components/dataset.rb', line 21
def blocks
[*dataset_components.map(&:block), block].compact
end
|
#build ⇒ Object
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_id ⇒ Object
36
37
38
|
# File 'lib/rom/components/dataset.rb', line 36
def relation_id
config.relation_id
end
|