Sha256: e74ee696efac5b581a0efd32f847029d9020014ba89d41be8057ff2b5bb2088e

Contents?: true

Size: 623 Bytes

Versions: 3

Compression:

Stored size: 623 Bytes

Contents

require 'memoist'

module TenantsHelper
  class ConfigLoader
    extend Memoist

    def initialize(config_path:)
      @config_path = config_path
      validate_config_path
    end

    def load_content
      Yamload::Loader.new(filename, dirname).content
    end
    memoize :load_content

    private

    def validate_config_path
      fail(Error, 'Invalid config path') if @config_path.blank? || !pathname.exist?
    end

    def pathname
      Pathname.new(@config_path)
    end
    memoize :pathname

    def dirname
      pathname.dirname
    end

    def filename
      pathname.basename('.yml')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tenants_helper-0.3.0 lib/tenants_helper/config_loader.rb
tenants_helper-0.2.0 lib/tenants_helper/config_loader.rb
tenants_helper-0.1.0 lib/tenants_helper/config_loader.rb