Sha256: 13ea77445f8cde8dcddd950340ac14f6bc396b1ce41381a86ecebe3cc8351d18

Contents?: true

Size: 685 Bytes

Versions: 1

Compression:

Stored size: 685 Bytes

Contents

# frozen_string_literal: true

require "refinements/string"

module Tana
  module Configuration
    # Handles loading of configuration with environment defaults.
    class Loader
      using Refinements::String

      def initialize model = Content, environment: ENV
        @model = model
        @environment = environment
      end

      def call
        model[
          accept: environment.fetch("TANA_API_ACCEPT", "application/json"),
          token: environment["TANA_API_TOKEN"],
          url: environment.fetch("TANA_API_URL", "https://europe-west1-tagr-prod.cloudfunctions.net")
        ]
      end

      private

      attr_reader :model, :environment
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tana-0.0.0 lib/tana/configuration/loader.rb