Class: Portable::Rendering::Row

Inherits:
Object
  • Object
show all
Defined in:
lib/portable/rendering/row.rb

Overview

Internal intermediary class that knows how to combine columns specification instances with their respective Realize pipelines.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(columns, resolver: Objectable.resolver) ⇒ Row

Returns a new instance of Row.



19
20
21
22
23
24
# File 'lib/portable/rendering/row.rb', line 19

def initialize(columns, resolver: Objectable.resolver)
  @resolver = resolver
  @columns  = columns.map { |column| Column.new(column, resolver: resolver) }

  freeze
end

Instance Attribute Details

#columnsObject (readonly)

:nodoc: all



17
18
19
# File 'lib/portable/rendering/row.rb', line 17

def columns
  @columns
end

#resolverObject (readonly)

:nodoc: all



17
18
19
# File 'lib/portable/rendering/row.rb', line 17

def resolver
  @resolver
end

Instance Method Details

#headersObject



30
31
32
# File 'lib/portable/rendering/row.rb', line 30

def headers
  columns.map(&:header)
end

#merge(other) ⇒ Object



38
39
40
# File 'lib/portable/rendering/row.rb', line 38

def merge(other)
  self.class.new(model_columns + other.model_columns, resolver: resolver)
end

#model_columnsObject



34
35
36
# File 'lib/portable/rendering/row.rb', line 34

def model_columns
  columns.map(&:column)
end

#render(object, time) ⇒ Object



26
27
28
# File 'lib/portable/rendering/row.rb', line 26

def render(object, time)
  columns.map { |column| column.transform(object, time) }
end