While looking at the source code for Capistrano today, I came across a nice idiom for making class-level accessors:
1 2 3 4 5 6 7 8 9 10 11 12 |
class Actor class << self attr_accessor :connection_factory attr_accessor :command_factory attr_accessor :transfer_factory attr_accessor :default_io_proc end self.connection_factory = DefaultConnectionFactory self.command_factory = Command self.transfer_factory = Transfer end |
Now you can use these class-level accessors:
1 2 3 |
Actor.connection_factory Actor.command_factory ... |