Module: ROM::Plugins::Relation::View

Defined in:
lib/rom/plugins/relation/view.rb,
lib/rom/plugins/relation/view/dsl.rb

Defined Under Namespace

Modules: ClassInterface Classes: DSL

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rom/plugins/relation/view.rb', line 7

def self.included(klass)
  super

  klass.class_eval do
    extend ClassInterface

    def self.attributes
      @__attributes__ ||= {}
    end
  end
end

Instance Method Details

#attributes(view_name = name) ⇒ Array<Symbol>

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.

Return column names that will be selected for this relation

By default we use dataset columns but first we look at configured attributes by ‘view` DSL

Returns:

  • (Array<Symbol>)


27
28
29
30
31
32
33
34
35
36
# File 'lib/rom/plugins/relation/view.rb', line 27

def attributes(view_name = name)
  header = self.class.attributes
    .fetch(view_name, self.class.attributes.fetch(:base))

  if header.is_a?(Proc)
    instance_exec(&header)
  else
    header
  end
end