lib/ctioga2/graphics/styles/base.rb in ctioga2-0.9 vs lib/ctioga2/graphics/styles/base.rb in ctioga2-0.10

- old
+ new

@@ -88,9 +88,22 @@ @attribute_types ||= {} @attribute_types[sym] = type return type end + # Define an attribute to be the alias for something else. + def self.alias_for(symbol, target) + target = target.to_sym + if ! @attribute_types[target] + raise "Declaring alias #{symbol} for unexisting target #{target}" + end + symbol = symbol.to_sym + @attribute_types[symbol] = @attribute_types[target] + @attributes << symbol + alias_method symbol, target + alias_method "#{symbol}=".to_sym, "#{target}=".to_sym + end + # Returns the type of an attribute, or _nil_ if there is no # attribute of that name. Handles sub-styles correctly. def self.attribute_type(symbol, fmt = "%s") name = symbol.to_s