Class: Spyro::ActionViewExtension::CollectionForHelper::Parser::Array

Inherits:
ActiveRecordRelation show all
Defined in:
lib/spyro/collections/parsers/array.rb

Instance Attribute Summary

Attributes inherited from Base

#unicollection

Instance Method Summary collapse

Methods inherited from ActiveRecordRelation

#actions, #body, #buttons, #cell, #data, #footer, #header, #populate_actions, #row

Methods inherited from Base

#hash_for_name, #link, #method_missing, #parse_default

Constructor Details

#initialize(model, helper, options) ⇒ Array

Returns a new instance of Array.



11
12
13
14
# File 'lib/spyro/collections/parsers/array.rb', line 11

def initialize model, helper, options
  super
  @array = @collection
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Spyro::ActionViewExtension::CollectionForHelper::Parser::Base

Instance Method Details

#parseObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/spyro/collections/parsers/array.rb', line 16

def parse
  if @array.first.try(:is_a?, ActiveRecord::Base)
    super
    return
  end
  if @unicollection.rows.empty?
    @array.each do |row|
      @unicollection.row do |r|
        [*row].each do |elem|
          r.add_elem UniData::Element.new(value: elem, name: "header", type: elem.class)
        end
      end
    end
  end

  @unicollection.add_meta :header, @unicollection.meta[:data]
end