Skip to content

Instantly share code, notes, and snippets.

@simplay
simplay / refactoring_using_metaprogrammin.rb
Created May 20, 2013 14:57
Refactoring in Ruby using dynamic methods and dynamic dispatch (1) using dynamic proxy that is also a blank slate (2) source: book - metaprogramming-ruby
# given class Computer: refactor me
class Computer
def initialize(computer_id, data_source)
@id = computer_id
@data_source = data_source
end
def mouse
info = @data_source.get_mouse_info(@id)
price = @data_source.get_mouse_price(@id)