class Mondrian::OLAP::Schema

See mondrian.pentaho.com/documentation/schema.php for more detailed description of Mondrian Schema elements.

Public Class Methods

define(name = nil, attributes = {}, &block) click to toggle source
# File lib/mondrian/olap/schema.rb, line 14
def self.define(name = nil, attributes = {}, &block)
  name, attributes = pre_process_arguments(name, attributes)
  new(name || 'default', attributes, &block)
end
new(name = nil, attributes = {}, parent = nil, &block) click to toggle source
Calls superclass method
# File lib/mondrian/olap/schema.rb, line 8
def initialize(name = nil, attributes = {}, parent = nil, &block)
  name, attributes = self.class.pre_process_arguments(name, attributes)
  pre_process_attributes(attributes)
  super(name, attributes, parent, &block)
end

Private Class Methods

pre_process_arguments(name, attributes) click to toggle source
# File lib/mondrian/olap/schema.rb, line 35
def self.pre_process_arguments(name, attributes)
  # if is called just with attributes hash and without name
  if name.is_a?(Hash) && attributes.empty?
    attributes = name
    name = nil
  end
  [name, attributes]
end

Public Instance Methods

define(name = nil, attributes = {}, &block) click to toggle source
# File lib/mondrian/olap/schema.rb, line 19
def define(name = nil, attributes = {}, &block)
  name, attributes = self.class.pre_process_arguments(name, attributes)
  pre_process_attributes(attributes)
  @attributes[:name] = name || @attributes[:name] || 'default' # otherwise connection with empty name fails
  instance_eval(&block) if block
  self
end
include_schema(shared_schema) click to toggle source
# File lib/mondrian/olap/schema.rb, line 27
def include_schema(shared_schema)
  shared_schema.class.elements.each do |element|
    instance_variable_get("@#{pluralize(element)}").concat shared_schema.send(pluralize(element))
  end
end
user_defined_cell_formatter(name, &block) click to toggle source
# File lib/mondrian/olap/schema_udf.rb, line 7
def user_defined_cell_formatter(name, &block)
  CellFormatter.new(name, &block)
end

Private Instance Methods

pre_process_attributes(attributes) click to toggle source
# File lib/mondrian/olap/schema.rb, line 44
def pre_process_attributes(attributes)
  unless attributes[:upcase_data_dictionary].nil?
    @upcase_data_dictionary = attributes.delete(:upcase_data_dictionary)
  end
end