Setting up configuration settings when writing a gem

前端 未结 2 816
醉梦人生
醉梦人生 2021-02-13 06:51

I\'m writing a gem which I would like to work with and without the Rails environment.

I have a Configuration class to allow configuration of the gem:

<
2条回答
  •  我寻月下人不归
    2021-02-13 07:45

    Try refactoring to:

    def self.configuration
      @configuration ||=  Configuration.new
    end
    
    def self.configure
      yield(configuration) if block_given?
    end
    

提交回复
热议问题