Sha256: e80086de387afd4dfbbbcc603bf38a95bb20c86d08d4e16b65d1627d378e541d

Contents?: true

Size: 654 Bytes

Versions: 1

Compression:

Stored size: 654 Bytes

Contents

require "yaml_properties/version"
require "active_support/core_ext/hash"

module YamlProperties
  def properties
    @properties ||= load_properties.with_indifferent_access
  end

  def reset!
    reset_properties
  end

  def reset_properties
    @properties = nil
  end

  def method_missing(key, *args, &block)
    return properties[key] if properties.keys.include? key.to_s

    super key, *args, &block
  end

  def override_attribute attribute, value
    properties[attribute] = value
  end

  private

  def yaml_file
    File.join %w(config properties.yml)
  end

  def load_properties
    YAML.load File.open(yaml_file)
  end

  extend self
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yaml_properties-0.0.8 lib/yaml_properties.rb