rgviz-rails 0.47 → 0.48

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,9 +3,8 @@ module Rgviz
3
3
  attr_reader :model_class
4
4
  attr_reader :adapter
5
5
 
6
- def initialize(model_class, query)
6
+ def initialize(model_class)
7
7
  @model_class = model_class
8
- @query = query
9
8
  @selects = []
10
9
  @joins = {}
11
10
  @labels = {}
@@ -25,7 +24,8 @@ module Rgviz
25
24
  end
26
25
  end
27
26
 
28
- def execute(options = {})
27
+ def execute(query, options = {})
28
+ @query = query
29
29
  @query = Parser.parse(@query, options) unless @query.kind_of?(Query)
30
30
 
31
31
  @table = Table.new
@@ -14,17 +14,23 @@ module Rgviz
14
14
  model = hash[:rgviz]
15
15
  conditions = hash[:conditions]
16
16
  extensions = hash[:extensions]
17
- query = params[:tq]
17
+ query = params[:tq] || 'select *'
18
18
  tqx = params[:tqx] || ''
19
19
 
20
20
  tqx = Rgviz::Tqx.parse(tqx)
21
21
 
22
22
  begin
23
- executor = Rgviz::Executor.new model, query
23
+ if model.is_a? Class and model < ActiveRecord::Base
24
+ executor = Rgviz::Executor.new model
25
+ elsif model.respond_to? :execute
26
+ executor = model
27
+ else
28
+ raise "The parameter to :rgviz => ... must extend from ActiveRecord::Base or respond to execute"
29
+ end
24
30
  options = {}
25
31
  options[:conditions] = conditions if conditions
26
32
  options[:extensions] = extensions if extensions
27
- table = executor.execute options
33
+ table = executor.execute query, options
28
34
 
29
35
  yield table if block_given?
30
36
 
@@ -9,8 +9,8 @@ describe Executor do
9
9
  end
10
10
 
11
11
  def exec(query, options = {})
12
- exec = Executor.new Person, query
13
- exec.execute options
12
+ exec = Executor.new Person
13
+ exec.execute query, options
14
14
  end
15
15
 
16
16
  def format_datetime(date)
metadata CHANGED
@@ -1,12 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgviz-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 85
5
- prerelease:
4
+ prerelease: false
6
5
  segments:
7
6
  - 0
8
- - 47
9
- version: "0.47"
7
+ - 48
8
+ version: "0.48"
10
9
  platform: ruby
11
10
  authors:
12
11
  - Ary Borenszweig
@@ -14,7 +13,7 @@ autorequire:
14
13
  bindir: bin
15
14
  cert_chain: []
16
15
 
17
- date: 2011-07-07 00:00:00 -03:00
16
+ date: 2011-07-08 00:00:00 -03:00
18
17
  default_executable:
19
18
  dependencies:
20
19
  - !ruby/object:Gem::Dependency
@@ -25,7 +24,6 @@ dependencies:
25
24
  requirements:
26
25
  - - ">="
27
26
  - !ruby/object:Gem::Version
28
- hash: 3
29
27
  segments:
30
28
  - 0
31
29
  version: "0"
@@ -72,7 +70,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
72
70
  requirements:
73
71
  - - ">="
74
72
  - !ruby/object:Gem::Version
75
- hash: 3
76
73
  segments:
77
74
  - 0
78
75
  version: "0"
@@ -81,14 +78,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
78
  requirements:
82
79
  - - ">="
83
80
  - !ruby/object:Gem::Version
84
- hash: 3
85
81
  segments:
86
82
  - 0
87
83
  version: "0"
88
84
  requirements: []
89
85
 
90
86
  rubyforge_project:
91
- rubygems_version: 1.4.2
87
+ rubygems_version: 1.3.7
92
88
  signing_key:
93
89
  specification_version: 3
94
90
  summary: rgviz for rails