Class: ROF::Filters::Bendo

Inherits:
ROF::Filter show all
Defined in:
lib/rof/filters/bendo.rb

Overview

If bendo server is set , add it into datasreams that contain an URl referencing bendo

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Bendo

Returns a new instance of Bendo.



7
8
9
# File 'lib/rof/filters/bendo.rb', line 7

def initialize(options = {})
  @bendo = options.fetch(:bendo_info)
end

Instance Method Details

#process(obj_list) ⇒ Object

for *-meta objects containing “URL”, sub in bendo string if provided



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rof/filters/bendo.rb', line 12

def process(obj_list)
  # NOTE: This was refactored to short-circuit the loop. A side-effect is that the code
  # is now returning the same object as was passed in. The previous behavior was that a
  # new object_list was created via the #map! method.
  return obj_list unless @bendo
  key_name_ends_in_meta_regexp = Regexp.new('(.+)-meta')
  obj_list.map! do |obj|
    obj.map do |key_name, value|
      if key_name =~ key_name_ends_in_meta_regexp
        if obj[key_name]["URL"]
          obj[key_name]["URL"] = obj[key_name]["URL"].sub("bendo:", @bendo)
        end
      end
    end
    obj
  end
end