Sha256: 3dc6ae409e0c04e954f7831af6768edcea3d6a4acb185550bdb6bf69531a230f

Contents?: true

Size: 453 Bytes

Versions: 30

Compression:

Stored size: 453 Bytes

Contents

# frozen_string_literal: true

module EnvSettings
  def env_prefix(new_prefix = nil)
    @env_prefix = new_prefix if new_prefix
    @env_prefix
  end

  def from_env(*method_names)
    builder = Sinclair.new(self)

    method_names.each do |method_name|
      env_key = [env_prefix, method_name].compact.join('_').upcase

      builder.add_class_method(method_name, cached: true) do
        ENV[env_key]
      end

      builder.build
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
sinclair-1.6.7 spec/support/models/env_settings.rb
sinclair-1.6.6 spec/support/models/env_settings.rb
sinclair-1.6.5 spec/support/models/env_settings.rb
sinclair-1.6.4 spec/support/models/env_settings.rb
sinclair-1.6.3 spec/support/models/env_settings.rb
sinclair-1.6.2 spec/support/models/env_settings.rb
sinclair-1.6.1 spec/support/models/env_settings.rb
sinclair-1.6.0 spec/support/models/env_settings.rb
sinclair-1.5.2 spec/support/models/env_settings.rb
sinclair-1.5.1 spec/support/models/env_settings.rb