lib/mondrian/olap/schema_element.rb in mondrian-olap-0.8.0 vs lib/mondrian/olap/schema_element.rb in mondrian-olap-1.1.0

- old
+ new

@@ -65,18 +65,34 @@ names.each do |name| next if name == :xml attr_reader pluralize(name).to_sym class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{name}(name=nil, attributes = {}, &block) - @#{pluralize(name)} << Schema::#{camel_case(name)}.new(name, attributes, self, &block) + new_element = Schema::#{camel_case(name)}.new(name, attributes, self, &block) + @#{pluralize(name)} << new_element + new_element end RUBY + if name == :annotations + class_eval <<-RUBY, __FILE__, __LINE__ + 1 + def annotations_hash + hash = {} + @annotationss.each do |annotations| + annotations.annotations.each do |annotation| + hash[annotation.name] = annotation.content + end + end + hash + end + RUBY + end end end - def self.content(type=nil) + def self.content(type = nil) return @content if type.nil? + attr_reader :content @content = type end attr_reader :xml_fragments def xml(string) @@ -84,11 +100,11 @@ fragment = Nokogiri::XML::DocumentFragment.parse(string) raise ArgumentError, "Invalid XML fragment:\n#{string}" if fragment.children.empty? @xml_fragments << string end - def to_xml(options={}) + def to_xml(options = {}) options[:upcase_data_dictionary] = @upcase_data_dictionary unless @upcase_data_dictionary.nil? Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml| add_to_xml(xml, options) end.to_xml end @@ -123,10 +139,10 @@ private def xmlized_attributes(options) # data dictionary values should be in uppercase if schema defined with :upcase_data_dictionary => true # or by default when using Oracle or LucidDB driver (can be overridden by :upcase_data_dictionary => false) - upcase_attributes = if options[:upcase_data_dictionary].nil? && %w(oracle luciddb).include?(options[:driver]) || + upcase_attributes = if options[:upcase_data_dictionary].nil? && %w(oracle luciddb snowflake).include?(options[:driver]) || options[:upcase_data_dictionary] self.class.data_dictionary_names else [] end