Sha256: c3395291b3f6d6e44ff6a76778eccf5fbaee32d0ce20bee510031bbe7a9a054e

Contents?: true

Size: 842 Bytes

Versions: 2

Compression:

Stored size: 842 Bytes

Contents

# frozen_string_literal: true

module AdequateJson
  class Configuration
    attr_accessor :use_model_name_for_collection_key, :collection_key, :serializers_module, :i18n_errors_scope

    def initialize
      @use_model_name_for_collection_key = false
      @collection_key = :collection
      @serializers_module = :serializers
      @i18n_errors_scope = %i[api errors]
    end

    def serializers_module_const
      AdequateJson.configuration.serializers_module.to_s.camelcase.constantize
    end
  end

  class ConfigurationBuilder
    def initialize(configuration)
      @configuration = configuration
    end

    def method_missing(name, *args, **kwargs)
      @configuration.send("#{name}=", *args, **kwargs)
    end

    def respond_to_missing?(name, _ = false)
      false unless @configuration.respond_to?(name)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
adequate_json-0.2.0 lib/adequate_json/configuration.rb
adequate_json-0.1.0 lib/adequate_json/configuration.rb