Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyClass
- def initialize(plugin_name=nil)
- end
- def method_missing(method_name)
- "#{plugin_name}".send(method_name)
- end
- end
- class Logger
- def initialize(store)
- @store = store
- end
- def info(message)
- @store.write(:info, message)
- end
- end
- class StandardOutputStore
- def write(level, message)
- puts "#{level}: #{message}"
- end
- end
- class FileStore
- def initalize(filename)
- @filename = filename
- end
- def write(level, message)
- File.open(@filename, "a") do |file|
- file.write("#{level}: #{message}")
- end
- end
- end
- logger = Logger.new(StandardOutputStore.new)
- logger.warn "hello"
- logger = Logger.new(FileStore.new("/tmp/log"))
- logger.warn "hello"
- module Plugins
- module Emoticons
- def smile
- ":-)"
- end
- end
- end
- Dir["/plugins/*.rb"].each {|file| require file }
- Plugins.constants.each do |constant|
- mod = Plugins.const_get constant
- TemplateMethods.send(:include, mod)
- end
Add Comment
Please, Sign In to add comment