Skip to content

Instantly share code, notes, and snippets.

@anaumov
Created January 15, 2014 07:18
Show Gist options
  • Save anaumov/8432161 to your computer and use it in GitHub Desktop.
Save anaumov/8432161 to your computer and use it in GitHub Desktop.
sample ActiveSupport::Configurable
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