Module: Rubiks::Mondrian

Defined in:
lib/rubiks/mondrian.rb,
lib/rubiks/mondrian/member.rb,
lib/rubiks/mondrian/cell_set.rb,
lib/rubiks/mondrian/connection.rb

Defined Under Namespace

Classes: CellSet, Connection, Member

Class Method Summary collapse

Class Method Details

.configObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rubiks/mondrian.rb', line 22

def self.config
  @config ||= begin
    if defined?(ActiveRecord)
      ar_config = ActiveRecord::Base.connection.config

      {
        :driver           => ar_config[:adapter],
        :host             => ar_config[:host],
        :database         => ar_config[:database],
        :username         => ar_config[:username],
        :password         => ar_config[:password]
      }
    else
      {}
    end
  end
end

.config=(new_config) ⇒ Object



18
19
20
# File 'lib/rubiks/mondrian.rb', line 18

def self.config=(new_config)
  @config = new_config
end

.connectionObject



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

def self.connection
  @connection ||= ::Rubiks::Mondrian::Connection.create(
    config.merge(:catalog_content => ::Rubiks.schema.to_xml)
  )
end

.execute(query) ⇒ Object



40
41
42
# File 'lib/rubiks/mondrian.rb', line 40

def self.execute(query)
  connection.execute(query)
end

.flush_schema_cacheObject

After the cache is flushed we must reset the connection



45
46
47
# File 'lib/rubiks/mondrian.rb', line 45

def self.flush_schema_cache
  connection.flush_schema_cache
end

.reset_connectionObject



49
50
51
52
53
54
# File 'lib/rubiks/mondrian.rb', line 49

def self.reset_connection
  connection.close
  @connection = ::Rubiks::Mondrian::Connection.create(
    config.merge(:catalog_content => ::Rubiks.schema.to_xml)
  )
end