Sha256: c5028017b890e72d9179ad46d826b46d796f3de182a0cf185089438e9165c724

Contents?: true

Size: 624 Bytes

Versions: 16

Compression:

Stored size: 624 Bytes

Contents

# This module allows to define module configuration variables.

# see https://viget.com/extend/easy-gem-configuration-variables-with-defaults
 
module Configuration
  def configuration
    yield self
  end
  def define_setting(name, default = nil)
    class_variable_set("@@#{name}", default)
    define_class_method "#{name}=" do |value|
      class_variable_set("@@#{name}", value)
    end
    define_class_method name do
      class_variable_get("@@#{name}")
    end
  end
  private
  def define_class_method(name, &block)
    (class << self; self; end).instance_eval do
      define_method name, &block
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rspreadsheet-0.5.3 lib/helpers/configuration.rb
rspreadsheet-0.5.1 lib/helpers/configuration.rb
rspreadsheet-0.5.0 lib/helpers/configuration.rb
rspreadsheet-0.4.9 lib/helpers/configuration.rb
rspreadsheet-0.4.8 lib/helpers/configuration.rb
rspreadsheet-0.4.7 lib/helpers/configuration.rb
rspreadsheet-0.4.5 lib/helpers/configuration.rb
rspreadsheet-0.4.4 lib/helpers/configuration.rb
rspreadsheet-0.4.3 lib/helpers/configuration.rb
rspreadsheet-0.4.2 lib/helpers/configuration.rb
rspreadsheet-0.4.1 lib/helpers/configuration.rb
rspreadsheet-0.3 lib/helpers/configuration.rb
rspreadsheet-0.2.15 lib/helpers/configuration.rb
rspreadsheet-0.2.14 lib/helpers/configuration.rb
rspreadsheet-0.2.12 lib/helpers/configuration.rb
rspreadsheet-0.2.11 lib/helpers/configuration.rb