configurations
configurations copied to clipboard
Instance-level configuration
I think it would be great to have instance specific configuration that takes precedence over the class-level configuration.
Example:
MyGem.new do |config|
config.foo = 'bar'
end
Does this make sense? I find it useful when multiple configurations are needed or even for testing purposes.
Interesting - could you elaborate on the use case a little bit more, specifically how this would be different from instantiating classes in your gem with parameters? e.g. :
MyGem.new(foo: 'bar')
I could definitely do what you said, and simply pass the configuration in on MyGem
initialization, but I was thinking it would be cool to have the same facilities and interface you created for the class-level configuration. One clear advantage is that it would be possible to take advantage of the restricted configuration options, for example.
Agreed! Your method is amazing, and I would really love to use it when instantiating objects. i.e. This:
obj = MyClass.new do |c|
c.conf1 = 'abc'
c.param2 = [1, 2, 3]
end
looks better to me than this:
obj = MyClass.new('abc', [1,2,3])
Anyway, Kudos for the project!