Sha256: 38c5e22f05952c8383c5423b3f2432d1d0173fa534e7b25e7dcac1d203196111
Contents?: true
Size: 946 Bytes
Versions: 1
Compression:
Stored size: 946 Bytes
Contents
require "yaml_properties/version" require "active_support/core_ext/hash" require "yaml" module YamlProperties def properties reset! if dev_environment @properties ||= load_properties.with_indifferent_access end attr_accessor :dev_environment 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 = YAML.load File.open(yaml_file) yaml end extend self end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yaml_properties-0.0.11 | lib/yaml_properties.rb |