Sha256: 15e06844049382cd9f93d4232ba6ce5e25215bb1ec1facb5b05dd1aa796e1697

Contents?: true

Size: 747 Bytes

Versions: 14

Compression:

Stored size: 747 Bytes

Contents

module ThreeScaleToolbox
  module AttributeFilters
    class ServiceIDFilterFromServiceRef
      include AttributeFilter

      attr_reader :remote, :service_ref, :service_id_key

      def initialize(remote, service_ref, service_id_key)
        @remote = remote
        @service_ref = service_ref
        @service_id_key = service_id_key
      end

      def filter(enumerable)
        svc_id = find_service
        enumerable.select { |e| e.key?(service_id_key) && e[service_id_key].to_s == svc_id.to_s }
      end

      private

      def find_service
        svc_id = -1
        Entities::Service.find(remote: remote, ref: service_ref).tap do |svc|
          svc_id = svc.id if !svc.nil?
        end
        svc_id
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
3scale_toolbox-1.0.1 lib/3scale_toolbox/attribute_filters/service_id_from_ref_filter.rb
3scale_toolbox-1.0.0 lib/3scale_toolbox/attribute_filters/service_id_from_ref_filter.rb
3scale_toolbox-0.20.0 lib/3scale_toolbox/attribute_filters/service_id_from_ref_filter.rb
3scale_toolbox-0.19.3 lib/3scale_toolbox/attribute_filters/service_id_from_ref_filter.rb
3scale_toolbox-0.19.2 lib/3scale_toolbox/attribute_filters/service_id_from_ref_filter.rb
3scale_toolbox-0.19.1 lib/3scale_toolbox/attribute_filters/service_id_from_ref_filter.rb
3scale_toolbox-0.19.0 lib/3scale_toolbox/attribute_filters/service_id_from_ref_filter.rb
3scale_toolbox-0.18.3 lib/3scale_toolbox/attribute_filters/service_id_from_ref_filter.rb
3scale_toolbox-0.18.2 lib/3scale_toolbox/attribute_filters/service_id_from_ref_filter.rb
3scale_toolbox-0.18.0 lib/3scale_toolbox/attribute_filters/service_id_from_ref_filter.rb
3scale_toolbox-0.17.1 lib/3scale_toolbox/attribute_filters/service_id_from_ref_filter.rb
3scale_toolbox-0.17.0 lib/3scale_toolbox/attribute_filters/service_id_from_ref_filter.rb
3scale_toolbox-0.16.0 lib/3scale_toolbox/attribute_filters/service_id_from_ref_filter.rb
3scale_toolbox-0.15.0 lib/3scale_toolbox/attribute_filters/service_id_from_ref_filter.rb