Class: ThreeScaleToolbox::AttributeFilters::ServiceIDFilterFromServiceRef

Inherits:
Object
  • Object
show all
Includes:
AttributeFilter
Defined in:
lib/3scale_toolbox/attribute_filters/service_id_from_ref_filter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(remote, service_ref, service_id_key) ⇒ ServiceIDFilterFromServiceRef

Returns a new instance of ServiceIDFilterFromServiceRef.



8
9
10
11
12
# File 'lib/3scale_toolbox/attribute_filters/service_id_from_ref_filter.rb', line 8

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

Instance Attribute Details

#remoteObject (readonly)

Returns the value of attribute remote.



6
7
8
# File 'lib/3scale_toolbox/attribute_filters/service_id_from_ref_filter.rb', line 6

def remote
  @remote
end

#service_id_keyObject (readonly)

Returns the value of attribute service_id_key.



6
7
8
# File 'lib/3scale_toolbox/attribute_filters/service_id_from_ref_filter.rb', line 6

def service_id_key
  @service_id_key
end

#service_refObject (readonly)

Returns the value of attribute service_ref.



6
7
8
# File 'lib/3scale_toolbox/attribute_filters/service_id_from_ref_filter.rb', line 6

def service_ref
  @service_ref
end

Instance Method Details

#filter(enumerable) ⇒ Object



14
15
16
17
# File 'lib/3scale_toolbox/attribute_filters/service_id_from_ref_filter.rb', line 14

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