Sha256: bcc19cffa436f627eb5a63ca388833a0c2381f91c4ac67a02f6b48e6ee12947b

Contents?: true

Size: 1.7 KB

Versions: 77

Compression:

Stored size: 1.7 KB

Contents

# encoding: UTF-8
#
# Copyright (c) 2010-2017 GoodData Corporation. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

module GoodData
  module Model
    class BlueprintField
      attr_reader :dataset_blueprint, :data

      def id
        @data[:id]
      end

      def initialize(data, dataset)
        @data = GoodData::Helpers.symbolize_keys(data)
        @data[:type] = @data[:type].to_sym
        @dataset_blueprint = dataset
      end

      # Returns the md object in associated project or throws error if not present
      #
      # @return [GoodData::MdObject] md object that is represented in the blueprint
      def in_project(project)
        GoodData::MdObject[id, project: project, client: project.client]
      end

      def method_missing(method_sym, *arguments, &block)
        if @data.key?(method_sym)
          @data[method_sym]
        else
          super
        end
      end

      def respond_to_missing?(method_name, include_private = false)
        if @data.key?(method_name)
          true
        else
          super
        end
      end

      def title
        @data[:title] || GoodData::Helpers.titleize(@data[:id])
      end

      # Validates the fields in the field
      #
      # @return [Array] returns list of the errors represented by hash structures
      def validate
        []
      end

      def ==(other)
        return false unless other.respond_to?(:data)
        @data == other.data
      end

      private

      def validate_presence_of(*fields)
        fields.reduce([]) do |a, e|
          data.key?(e) && !data[e].blank? ? a : a + [e]
        end
      end
    end
  end
end

Version data entries

77 entries across 77 versions & 1 rubygems

Version Path
gooddata-2.3.1-java lib/gooddata/models/blueprint/blueprint_field.rb
gooddata-2.3.1 lib/gooddata/models/blueprint/blueprint_field.rb
gooddata-2.3.0-java lib/gooddata/models/blueprint/blueprint_field.rb
gooddata-2.3.0 lib/gooddata/models/blueprint/blueprint_field.rb
gooddata-2.2.0-java lib/gooddata/models/blueprint/blueprint_field.rb
gooddata-2.2.0 lib/gooddata/models/blueprint/blueprint_field.rb
gooddata-2.1.19-java lib/gooddata/models/blueprint/blueprint_field.rb
gooddata-2.1.19 lib/gooddata/models/blueprint/blueprint_field.rb
gooddata-2.1.17-java lib/gooddata/models/blueprint/blueprint_field.rb
gooddata-2.1.17 lib/gooddata/models/blueprint/blueprint_field.rb
gooddata-2.1.15-java lib/gooddata/models/blueprint/blueprint_field.rb
gooddata-2.1.15 lib/gooddata/models/blueprint/blueprint_field.rb
gooddata-2.1.14-java lib/gooddata/models/blueprint/blueprint_field.rb
gooddata-2.1.14 lib/gooddata/models/blueprint/blueprint_field.rb
gooddata-2.1.13-java lib/gooddata/models/blueprint/blueprint_field.rb
gooddata-2.1.13 lib/gooddata/models/blueprint/blueprint_field.rb
gooddata-2.1.12-java lib/gooddata/models/blueprint/blueprint_field.rb
gooddata-2.1.12 lib/gooddata/models/blueprint/blueprint_field.rb
gooddata-2.1.11-java lib/gooddata/models/blueprint/blueprint_field.rb
gooddata-2.1.11 lib/gooddata/models/blueprint/blueprint_field.rb