Sha256: 42997cc582c84dbe6783f357c9610a78830fcd1ccfca63db998b0f08069ad66b

Contents?: true

Size: 1.27 KB

Versions: 9

Compression:

Stored size: 1.27 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.

require_relative '../types/param'
require_relative '../types/special/types'

module GoodData
  module LCM2
    module Dsl
      class TypeDsl
        def initialize
          @params = {}

          new_param
        end

        attr_reader :params

        def array_of(type)
          Type::ArrayType.new(type)
        end

        def instance_of(type)
          type.new
        end

        def one_of(_type)
          Type::EnumType.new
        end

        def new_param
          @param = Type::Param.new
        end

        def description(desc)
          @param.description = desc
        end

        def param(name, type, opts = {})
          @param.name = name
          @param.type = type
          @param.opts = opts

          @params[name] = {
            name: @param.name,
            type: @param.type,
            opts: @param.opts,
            description: @param.description,
            category: @param.type.class.const_get(:CATEGORY)
          }

          # Create new instance of param
          new_param
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
gooddata-1.1.0-java lib/gooddata/lcm/dsl/type_dsl.rb
gooddata-1.1.0 lib/gooddata/lcm/dsl/type_dsl.rb
gooddata-1.0.2-java lib/gooddata/lcm/dsl/type_dsl.rb
gooddata-1.0.2 lib/gooddata/lcm/dsl/type_dsl.rb
gooddata-1.0.1 lib/gooddata/lcm/dsl/type_dsl.rb
gooddata-1.0.1-java lib/gooddata/lcm/dsl/type_dsl.rb
gooddata-1.0.0-java lib/gooddata/lcm/dsl/type_dsl.rb
gooddata-1.0.0 lib/gooddata/lcm/dsl/type_dsl.rb
gooddata-0.6.54 lib/gooddata/lcm/dsl/type_dsl.rb