Sha256: d1c5c644f211428b41adfdb0501218bb36fe115c57643bf51049be7a0da962ef

Contents?: true

Size: 874 Bytes

Versions: 3

Compression:

Stored size: 874 Bytes

Contents

# encoding: UTF-8

require_relative '../columns/attribute'

module GoodData
  module Model
    ##
    # A GoodData attribute that represents a data set's connection point or a data set
    # without a connection point
    #
    class Anchor < Attribute
      def initialize(column, schema)
        if column
          super
        else
          super({ :type => 'anchor', :name => 'id' }, schema)
          @labels = []
          @primary_label = nil
        end
      end

      def table
        @table ||= 'f_' + @schema.name
      end

      def to_maql_create
        maql = super
        maql += "\n# Connect '#{title}' to all attributes of this data set\n"
        @schema.attributes.values.each do |c|
          maql += "ALTER ATTRIBUTE {#{c.identifier}} ADD KEYS " \
                + "{#{table}.#{c.key}};\n"
        end
        maql
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gooddata-0.6.4 lib/gooddata/models/attributes/anchor.rb
gooddata-0.6.3 lib/gooddata/models/attributes/anchor.rb
gooddata-0.6.2 lib/gooddata/models/attributes/anchor.rb