Module: ActiveRecord::LookML::Core::ClassMethods

Defined in:
lib/active_record/lookml/core.rb

Instance Method Summary collapse

Instance Method Details

#to_lookml(table_name_prefix: 'wantedly-1371.rdb.pulse_') ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/active_record/lookml/core.rb', line 7

def to_lookml(table_name_prefix: 'wantedly-1371.rdb.pulse_')
  fields = attribute_types.map do |attribute, type|
    attribute_type_to_set_detail_field(attribute, type)
  end.compact

  set_block = Block.new(type: "set", name: "detail") do |b|
    b << ArrayField.new(name: "fields", values: fields)
  end

  Block.new(type: "view", name: "pulse_onboarding_statuses") do |b|
    b << Field.new(name: "sql_table_name", value: "`#{table_name_prefix}#{table_name}`;;")
    attribute_types.each do |attribute, type|
      b << attribute_type_to_block(attribute, type)
    end
    b << set_block
  end.to_lookml
end