Sha256: ae8ea39ea875627cf4330b6c69d75869d21d88b7c2bdfb6424e15f6890033115

Contents?: true

Size: 570 Bytes

Versions: 4

Compression:

Stored size: 570 Bytes

Contents

module Querifier
  module Config
    DEFAULTS_CONFIGS = {
      where_param: :where,
      order_param: :order,
      filter_param: :filter
    }.freeze

    module_function

    DEFAULTS_CONFIGS.each do |key, value|
      define_method key do
        instance_variable_get("@#{key}") || instance_variable_set("@#{key}", value)
      end

      define_method "#{key}=" do |v|
        instance_variable_set("@#{key}", v)
      end
    end

    # This is mostly useful for the tests
    def reset!
      DEFAULTS_CONFIGS.each { |k, v| send("#{k}=", v) }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
querifier-0.2.3 lib/querifier/config.rb
querifier-0.2.2 lib/querifier/config.rb
querifier-0.1.1 lib/querifier/config.rb
querifier-0.1.0 lib/querifier/config.rb