Sha256: 6b3755be1ce69b5eef88e6bf8cf49830c7cc7b91769e4ab02d437607d6f57f61
Contents?: true
Size: 976 Bytes
Versions: 1
Compression:
Stored size: 976 Bytes
Contents
require "yaml_properties/version" require "active_support/core_ext/hash" require "yaml" require "erb" 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 ERB.new(File.read(yaml_file)).result yaml end extend self end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shutl_yaml_properties-0.0.13 | lib/yaml_properties.rb |