Skip to content

Instantly share code, notes, and snippets.

@vlado
Last active December 23, 2015 12:19
Show Gist options
  • Save vlado/6634732 to your computer and use it in GitHub Desktop.
Save vlado/6634732 to your computer and use it in GitHub Desktop.
How to write config block for gems. Inspired by http://rarlindseysmash.com/posts/config-and-generators-in-gems
module Jem
class << self
attr_accessor :configuration
end
def self.configure
self.configuration ||= Configuration.new
yield(configuration)
end
class Configuration
attr_accessor :option
def initialize
@option = 'default_option'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment