Class: CanvasLinkMigrator::LinkReplacer
- Inherits:
-
Object
- Object
- CanvasLinkMigrator::LinkReplacer
- Defined in:
- lib/canvas_link_migrator/link_replacer.rb
Class Method Summary collapse
- .recursively_sub_placeholders!(object, links) ⇒ Object
-
.sub_placeholders!(html, links) ⇒ Object
returns false if no substitutions were made.
Class Method Details
.recursively_sub_placeholders!(object, links) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/canvas_link_migrator/link_replacer.rb', line 35 def self.recursively_sub_placeholders!(object, links) subbed = false case object when Hash object.each_value { |o| subbed = true if recursively_sub_placeholders!(o, links) } when Array object.each { |o| subbed = true if recursively_sub_placeholders!(o, links) } when String subbed = sub_placeholders!(object, links) end subbed end |
.sub_placeholders!(html, links) ⇒ Object
returns false if no substitutions were made
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/canvas_link_migrator/link_replacer.rb', line 23 def self.sub_placeholders!(html, links) subbed = false links.each do |link| new_value = link[:new_value] || link[:old_value] if html.gsub!(link[:placeholder], new_value) link[:replaced] = true subbed = true end end subbed end |