Code submission for: Jordan Hudgens

Submission Status: Passed

Submitted for: January 4 - Perform Monkey Patching in Ruby on Isolated Classes

Submitted at: July 31, 2017

module RubyContent
  refine String do
    def commentize
      "# #{self}"
    end
  end
end

module HtmlContent
  refine String do
    def commentize
      ""
    end
  end
end

class ContentController
  using RubyContent

  def initialize(word)
    @word = word
  end

  def hidden_content
    @word.commentize
  end
end

class HtmlController
  using HtmlContent

  def initialize(word)
    @word = word
  end

  def hidden_content
    @word.commentize
  end
end
Unsupported Browser

devCamp does not support ancient browsers.
Install a modern version for best experience.