query-interface-server 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c130d25257242b78e995068d4bce9cca150258f0
4
- data.tar.gz: b15bcad3ca4ed37a0d549561813ade1d51c4b93f
3
+ metadata.gz: 304cbafb396d154cfcffef663d9e37d5b478fa65
4
+ data.tar.gz: 3b14bc4045f7ad6637eb5e7aeef72b11cb227a59
5
5
  SHA512:
6
- metadata.gz: 8500c4301578ce5dc00384d92418c9d85286e66cb51fe4e8833e225c13e0c4de9f8bddb4c433656ca77fbc42fc125db5b415048af05484d73d31f22cece2c5e9
7
- data.tar.gz: d5f67264a46094fc397048e1c34f4df38affa21db5e5aff1c96eecdda4cdae1b079206e01ae5cb1323ada1c845482ed77c7718a375217ce6bf4f7611ee555441
6
+ metadata.gz: 889f264e1d9e60fb0b3e7bc27d126c1c8c790fd17e2f141ce7f3c15b163151685fa4a0acbca594fe162a7a40a0625b1715a2b7fa1a0f801e25dff381a8014556
7
+ data.tar.gz: 1cd5efc902852da170dc3276cc2438ec05159a953181683fabaa290f1c99673f0e7bd71ed8e87d80a7a1a3bd6081eb2b2fc37d33a507355c05625f047aeefd71
@@ -16,7 +16,8 @@ module QueryInterface
16
16
 
17
17
  module InstanceMethods
18
18
 
19
- attr_writer :context, :context_type
19
+ attr_writer :context_type
20
+ attr_accessor :context
20
21
 
21
22
  def validate_transformation(transformation)
22
23
  methods = {
@@ -43,10 +44,6 @@ module QueryInterface
43
44
  @context_type ||= :dataset
44
45
  end
45
46
 
46
- def context
47
- @context ||= query_model.filter.select_all(query_model.table_name)
48
- end
49
-
50
47
  def id_selector
51
48
  primary_key = self.context.model.primary_key ? self.context.model.primary_key : :id
52
49
  "#{self.context.model.table_name}__#{primary_key}".to_sym
@@ -119,12 +116,12 @@ module QueryInterface
119
116
  end
120
117
 
121
118
  def query
119
+ @context = query_model.filter.select_all(query_model.table_name)
122
120
  transformations = params[:transformations] || []
123
121
  transformations = JSON.parse(transformations) unless transformations.is_a?(Array)
124
122
  transformations.each do |transformation|
125
- method, param, context_type = self.validate_transformation(transformation)
123
+ method, param, self.context_type = self.validate_transformation(transformation)
126
124
  self.context = self.send(method, param)
127
- self.context_type = context_type
128
125
  end
129
126
  self.context = self.default_order if self.context_type == :dataset
130
127
  respond_with(self.context)
@@ -1,7 +1,7 @@
1
1
  module QueryInterface
2
2
  module Server
3
3
 
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
 
6
6
  end
7
7
  end
@@ -56,13 +56,6 @@ describe QueryInterface, type: :controller do
56
56
  controller.context.should eq(context)
57
57
  end
58
58
 
59
- it "creates a new context if non is present" do
60
- context = double("context")
61
- controller.query_model.should_receive(:filter).and_return(foos)
62
- foos.should_receive(:select_all).with(:foo_table).and_return(context)
63
- controller.context.should eq(context)
64
- assigns(:context).should eq(context)
65
- end
66
59
  end
67
60
 
68
61
  end
@@ -150,6 +143,18 @@ describe QueryInterface, type: :controller do
150
143
  assigns(:context).should == filtered
151
144
  response.should be_ok
152
145
  end
146
+
147
+ it "creates a new context if none is present" do
148
+ context = double("context")
149
+ controller.query_model.should_receive(:filter).and_return(foos)
150
+ controller.stub(:default_order).and_return(context)
151
+ foos.should_receive(:select_all).with(:foo_table).and_return(context)
152
+
153
+ get :query, transformations: [], format: :json
154
+ controller.context.should eq(context)
155
+ assigns(:context).should eq(context)
156
+ response.should be_ok
157
+ end
153
158
  end
154
159
 
155
160
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: query-interface-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Kopecky <andreas.kopecky@radarservices.com>
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-10-11 00:00:00.000000000 Z
13
+ date: 2013-10-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sequel