Sha256: d580698911de2a56abbb77cefba16c0338fef8af268f62aad5f40be5e12eabd7

Contents?: true

Size: 2 KB

Versions: 2

Compression:

Stored size: 2 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 'base_action'

module GoodData
  module LCM2
    class PrintModes < BaseAction
      DESCRIPTION = 'Print Modes'

      PARAMS = {
      }

      class << self
        def call(params)
          # Check if all required parameters were passed
          BaseAction.check_params(PARAMS, params)

          results = []
          GoodData::LCM2::MODES.keys.each_with_index do |mode, index|
            actions = GoodData::LCM2::MODES[mode]
            action_names = actions.map do |k, _action|
              params_length = k.const_get(:PARAMS).keys.length
              k.short_name + ("\n" * (params_length > 1 ? params_length - 1 : 0))
            end

            params = actions.map do |action|
              action.const_get(:PARAMS).map do |_k, param|
                param[:name]
              end
            end

            types = actions.map do |action|
              action.const_get(:PARAMS).map do |_k, param|
                param[:type]
                # param[:type].class.short_name
              end
            end

            required = actions.map do |action|
              action.const_get(:PARAMS).map do |_k, param|
                param[:opts][:required]
              end
            end

            defaults = actions.map do |action|
              action.const_get(:PARAMS).map do |_k, param|
                param[:opts][:default]
              end
            end

            results << {
              '#' => index,
              mode: mode,
              actions: action_names.join("\n"),
              params: params.join("\n"),
              types: types.join("\n"),
              required: required.join("\n"),
              default: defaults.join("\n")
            }
          end

          # Return results
          results
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gooddata-0.6.51 lib/gooddata/lcm/actions/print_modes.rb
gooddata-0.6.50 lib/gooddata/lcm/actions/print_modes.rb