Class: Mondrian::Schema

Inherits:
SchemaElement show all
Defined in:
lib/mondrian/schema.rb

Overview

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

Defined Under Namespace

Classes: AggExclude, AggFactCount, AggForeignKey, AggIgnoreColumn, AggLevel, AggMeasure, AggName, AggPattern, CalculatedMember, CalculatedMemberProperty, Closure, Cube, Dimension, DimensionUsage, Formula, Hierarchy, Join, KeyExpression, Level, Measure, MeasureExpression, NameExpression, OrdinalExpression, Property, Sql, Table, View

Instance Attribute Summary

Attributes inherited from SchemaElement

#xml_fragments

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SchemaElement

attributes, content, data_dictionary_names, elements, #to_xml, #xml

Constructor Details

#initialize(name = nil, attributes = {}, &block) ⇒ Schema

Returns a new instance of Schema.



7
8
9
10
11
# File 'lib/mondrian/schema.rb', line 7

def initialize(name = nil, attributes = {}, &block)
  name, attributes = self.class.pre_process_arguments(name, attributes)
  pre_process_attributes(attributes)
  super(name, attributes, &block)
end

Class Method Details

.define(name = nil, attributes = {}, &block) ⇒ Object



13
14
15
16
# File 'lib/mondrian/schema.rb', line 13

def self.define(name = nil, attributes = {}, &block)
  name, attributes = pre_process_arguments(name, attributes)
  new(name || 'default', attributes, &block)
end

Instance Method Details

#define(name = nil, attributes = {}, &block) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/mondrian/schema.rb', line 18

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) ⇒ Object



26
27
28
29
30
# File 'lib/mondrian/schema.rb', line 26

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