Sha256: dc2598cdd00f4525708e7cb37d0abff7512684073fae9f44d307aa048fb3d9e4

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 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 SegmentsFilter < BaseAction
      DESCRIPTION = 'Filter Segments'

      PARAMS = define_params(self) do
        description 'Segments to manage'
        param :segments, array_of(instance_of(Type::SegmentType)), required: true

        description 'Segments to provision'
        param :segments_filter, array_of(instance_of(Type::StringType)), required: false
      end

      class << self
        def call(params)
          filtered_segments = params.segments
          if params.segments_filter
            segments_filter = params.segments_filter.map(&:downcase)

            filtered_segments = params.segments.select do |segment|
              segments_filter.include?(segment.segment_id.downcase)
            end
          end

          # Return results
          {
            results: filtered_segments,
            params: {
              segments: filtered_segments
            }
          }
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gooddata-0.6.53 lib/gooddata/lcm/actions/segments_filter.rb
gooddata-0.6.52 lib/gooddata/lcm/actions/segments_filter.rb