The decorator pattern is used to extend the functionality of a certain object in a runtime. In a statically typed language you need to define decorator interface, then subclass from it and initialize the component (object) that you are decorating.
class Parser
def parse(type)
puts 'The Parser class received the parse method'
if type == :xml
puts 'An instance of the XmlParser class received the parse message'
elsif type == :json
puts 'An instance of the JsonParser class received the parse message'
end
end
end