Sha256: d83dc395f8442dabffc098e8914e5a6f25de14e999fea2f2d75dd22ec2df8137
Contents?: true
Size: 849 Bytes
Versions: 1
Compression:
Stored size: 849 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 key_present? key super key, *args, &block end def override_attribute attribute, value unless key_present? attribute raise ArgumentError, "Trying to override non-existent property `#{attribute}' with `#{value}'" end properties[attribute] = value end private def key_present? key properties.keys.include? key.to_s end 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.9 | lib/yaml_properties.rb |