Skip to content

Instantly share code, notes, and snippets.

@afa
Forked from anaumov/gist:8432161
Created January 15, 2014 11:51
Show Gist options
  • Save afa/8434886 to your computer and use it in GitHub Desktop.
Save afa/8434886 to your computer and use it in GitHub Desktop.
class CarConfig
include ActiveSupport::Configurable
config_accessor :brand
end
class Car
attr_accessor :brand
def initialize
self.brand = self.class.config.brand
end
class << self
attr_reader :config
def configure
@config ||= CarConfig.new
yield @config if block_given?
end
end
end
Car.configure do |config|
config.brand = 'Volvo'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment