Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please make it easy to set the olap connection #22

Open
kwerle opened this issue Aug 18, 2017 · 1 comment
Open

Please make it easy to set the olap connection #22

kwerle opened this issue Aug 18, 2017 · 1 comment

Comments

@kwerle
Copy link

kwerle commented Aug 18, 2017

The backtrace when you don't set the connection at all:

NoMethodError (undefined method `[]' for nil:NilClass):
  mondrian-olap (0.8.0) lib/mondrian/olap/connection.rb:15:in `initialize'
  mondrian-rest-0.7.0 (java) lib/mondrian_rest/api_helpers.rb:13:in `olap'
  mondrian-rest-0.7.0 (java) lib/mondrian_rest/api.rb:70:in `block in GET cubes  /'

Setting the olap connection in the env is possible, but kind of a hack. It would be exceptionally nice if there were some class or something where you could set the connection "globally" so that the library could grab ahold of it.

# If you want to set the connection, just call ConnectionClass.connection = my_connection
# Otherwise it will read env['mondrian-olap.params']
class ConnectionClass
  @@connection = nil
  def self.connection=(connection); @@connection = connection; end
  def self.connection
    return @@connection ||= Mondrian::OLAP::Connection.new(env['mondrian-olap.params'])
  end
end

@jazzido
Copy link
Owner

jazzido commented Aug 22, 2017

Looks good, can you send a PR? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants