Module: Kodekopelli::ExpandableProperties
- Defined in:
- lib/kodekopelli/expandable_properties.rb
Overview
This module encapsulates functionality related to manipulating expandable properties. In this context, expandable properties refer to those properties that may contain as substrings other properties to be substituted from an arbitrary property store, like a Hash.
Example Properties
property.not.expandable=world
property.expandable=Hello, ${property.not.expandable}! # => Hello, world!
property.nested.expandables=Not another ${property.expandable}.
# => Not another Hello, world!
Please note that the order of the properties above is very important. For example, if the property keyed by property.expandable had been listed before property property.not.expandable, its value would have remained Hello, ${property.not.expandable}!
with no expansions being performed.
Class Method Summary collapse
-
.replace_expandables(property_value, property_hash) ⇒ Object
Given a property value that may or may not contain expansion directives of the form $key and a hash containing pre-existing properties, this function returns a string with property values substituted for the expansion directives.
Class Method Details
.replace_expandables(property_value, property_hash) ⇒ Object
Given a property value that may or may not contain expansion directives of the form $key and a hash containing pre-existing properties, this function returns a string with property values substituted for the expansion directives.
:call-seq:
ExpandableProperties.replace_expandables(string, hash) -> string
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/kodekopelli/expandable_properties.rb', line 32 def ExpandableProperties.(property_value, property_hash) if(property_value.nil? || property_hash.nil?) raise "Both a property value and property hash must be provided." end modified_value = String.new(property_value) (modified_value).each {|| (, modified_value, property_hash[]) } modified_value end |