rgviz-rails 0.4 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/rails/init.rb +17 -15
  2. metadata +3 -3
data/rails/init.rb CHANGED
@@ -1,21 +1,23 @@
1
1
  config.after_initialize do
2
- module ::ActionControlller
3
- class Base
4
- def render(*args)
5
- if args.length == 1 && args[0].kind_of?(Hash)
6
- hash = args.first
7
- case hash[:rgviz]
8
- when nil then super
9
- else
10
- model = hash[:rgviz]
11
- query = params[:tq]
12
- executor = Rgviz::Executor.new model, Rgviz::Parser.new(query).parse
13
- table = executor.execute
14
- super :text => "google.visualization.Query.setResponse({version:'0.6',reqId:'0',status:'ok',sig:'5982206968295329967',table:#{table.to_json}});"
15
- end
2
+ class ::ActionController::Base
3
+ alias_method :original_render, :render
4
+ def render(*args, &block)
5
+ if args.length == 1 && args[0].kind_of?(Hash)
6
+ hash = args.first
7
+ case hash[:rgviz]
8
+ when nil then original_render *args, &block
16
9
  else
17
- super
10
+ model = hash[:rgviz]
11
+ query = params[:tq]
12
+ version = args[:version]
13
+ reqId = args[:reqId]
14
+ sig = args[:sig]
15
+ executor = Rgviz::Executor.new model, Rgviz::Parser.new(query).parse
16
+ table = executor.execute
17
+ original_render :text => "google.visualization.Query.setResponse({version:'#{version}',reqId:'#{reqId}',status:'ok',sig:'#{sig}',table:#{table.to_json}});"
18
18
  end
19
+ else
20
+ original_render *args, &block
19
21
  end
20
22
  end
21
23
  end
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgviz-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 4
9
- version: "0.4"
8
+ - 5
9
+ version: "0.5"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ary Borenszweig