Sha256: 284a1127251c11cfb0e6ad4b6f76f2a45d154fb8c96a8c7f7927fc163240db3f

Contents?: true

Size: 1.27 KB

Versions: 77

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 'base_middleware'

module GoodData
  module Bricks
    # Converts params from double underscore notation to nested hash under 'config'
    # Parameters starting GDC_ are considered system params and aren't converted.
    #
    # This is useful because the executor platform can currently
    # do just key-value parameters. Also it makes it easier for
    # a user, as there aren't as much curly braces.
    #
    #
    # ### Examples
    # If you pass params in form:
    # {"my__namespace__param": "value"}
    #
    # you'll get:
    # {"my": {"namespace": {"param": value}}}
    class UndotParamsMiddleware < Bricks::Middleware
      def call(params)
        params = params.to_hash
        unless params['config']
          # split the params to those starting with GDC and those that don't, put other params under config
          gdc_params, other_params = params.partition { |k, _| k =~ /GDC_.*/ }.map { |h| Hash[h] }
          params = gdc_params.merge('config' => other_params.undot)
        end
        @app.call(params)
      end
    end
  end
end

Version data entries

77 entries across 77 versions & 1 rubygems

Version Path
gooddata-2.3.1-java lib/gooddata/bricks/middleware/undot_params_middleware.rb
gooddata-2.3.1 lib/gooddata/bricks/middleware/undot_params_middleware.rb
gooddata-2.3.0-java lib/gooddata/bricks/middleware/undot_params_middleware.rb
gooddata-2.3.0 lib/gooddata/bricks/middleware/undot_params_middleware.rb
gooddata-2.2.0-java lib/gooddata/bricks/middleware/undot_params_middleware.rb
gooddata-2.2.0 lib/gooddata/bricks/middleware/undot_params_middleware.rb
gooddata-2.1.19-java lib/gooddata/bricks/middleware/undot_params_middleware.rb
gooddata-2.1.19 lib/gooddata/bricks/middleware/undot_params_middleware.rb
gooddata-2.1.17-java lib/gooddata/bricks/middleware/undot_params_middleware.rb
gooddata-2.1.17 lib/gooddata/bricks/middleware/undot_params_middleware.rb
gooddata-2.1.15-java lib/gooddata/bricks/middleware/undot_params_middleware.rb
gooddata-2.1.15 lib/gooddata/bricks/middleware/undot_params_middleware.rb
gooddata-2.1.14-java lib/gooddata/bricks/middleware/undot_params_middleware.rb
gooddata-2.1.14 lib/gooddata/bricks/middleware/undot_params_middleware.rb
gooddata-2.1.13-java lib/gooddata/bricks/middleware/undot_params_middleware.rb
gooddata-2.1.13 lib/gooddata/bricks/middleware/undot_params_middleware.rb
gooddata-2.1.12-java lib/gooddata/bricks/middleware/undot_params_middleware.rb
gooddata-2.1.12 lib/gooddata/bricks/middleware/undot_params_middleware.rb
gooddata-2.1.11-java lib/gooddata/bricks/middleware/undot_params_middleware.rb
gooddata-2.1.11 lib/gooddata/bricks/middleware/undot_params_middleware.rb