Sha256: 8b75cd33a888702d933f552a189b887def091f06cac4aec571c39dfd6ffa4f02

Contents?: true

Size: 621 Bytes

Versions: 6

Compression:

Stored size: 621 Bytes

Contents

require 'yaml'
require 'active_support/core_ext/hash/indifferent_access'

module Pears
  module Provider
    # Used for loading simple YAML file locally.
    class RailsConfig < Base
      def initialize(*path_parts, on_failure: :raise)
        file = path_parts.pop
        file_path = Rails.root.join('config', *path_parts, "#{file}.yml")
        yaml_data = File.read(file_path)
        @data = parse_yaml(yaml_data)
      rescue Errno::ENOENT,
          Pears::InvalidProviderData => error
        if on_failure == :null
          @data = {}
        else
          raise error
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pears-0.3.5 lib/pears/provider/rails_config.rb
pears-0.3.4 lib/pears/provider/rails_config.rb
pears-0.3.2 lib/pears/provider/rails_config.rb
pears-0.3.1 lib/pears/provider/rails_config.rb
pears-0.3.0 lib/pears/provider/rails_config.rb
pears-0.2.0 lib/pears/provider/rails_config.rb