query-interface-client 1.0.0 → 1.0.1

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: 4ac7454c6d84fe9a489332b2d574e9f259d053d2
4
- data.tar.gz: 34bb5ca953fefd6ae3a878ca03da4a88e3c8c463
3
+ metadata.gz: 1de90e97a3cf9d375a5168dca8bb9aeb7363c152
4
+ data.tar.gz: 0e829e485816ebefdc72ffb325e79413ee451036
5
5
  SHA512:
6
- metadata.gz: 06b9c334f0d080c86b5e3ebbdfff45d1db0b56f95f62e0ed6200ec29be5515e4d2bbfc3b321db25effa99c3eefd955f9d60f43fb7522f2e3e96817cd0233c045
7
- data.tar.gz: 96bcf3f96c4659d64de86f6f25dbe5caf41190bd56599bbcb45187b87ce2eef436702c5917285a894a7ec237ce04e3ae45f972b4eb3ee3e14c0ecc1063730dcd
6
+ metadata.gz: 21062e0c9e0ccf4d841fccac28d38112fe37ec68db58f6bd6f3055882bf99317f59e15e9ca0a6ee4e3da8e88184c58b3627ef55e679a43346259803d01378398
7
+ data.tar.gz: 76dbea21f9561961a0bffa363e8ff8cb8c62877ce01857a65527ca5ed30eb1141ec6cf2ca8ae9aa319ead1628b9aa7524f71f945488748138346e0701d89d582
@@ -79,6 +79,10 @@ module QueryInterface
79
79
  self.result ||= self.do_query()
80
80
  end
81
81
 
82
+ def to_param
83
+ persisted? ? to_key.join('-') : nil
84
+ end
85
+
82
86
  def paginate(page: 1, per_page: 10)
83
87
  query = self.copy
84
88
  query.add_transformation(:paginate, {page: page, per_page: per_page})
@@ -1,7 +1,7 @@
1
1
  module QueryInterface
2
2
  module Client
3
3
 
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
 
6
6
  end
7
7
  end
@@ -82,7 +82,7 @@ describe QueryInterface::Client::LazyQuery do
82
82
  query_copy = subject.new(model)
83
83
  query.should_receive(:copy).and_return(query_copy)
84
84
  query.with(:c)
85
- query_copy.transformations.should eq([{transformation: :with, parameter: :c}])
85
+ query_copy.transformations.should eq([{transformation: :with, parameter: {field: :c}}])
86
86
  end
87
87
  end
88
88
 
@@ -105,8 +105,8 @@ describe QueryInterface::Client::LazyQuery do
105
105
  {transformation: :filter, parameter: {field: :a, value: :b}},
106
106
  {transformation: :filter, parameter: {field: :c, value: :d}},
107
107
  {transformation: :filter, parameter: {field: :e, value: :f}},
108
- {transformation: :with, parameter: :x},
109
- {transformation: :with, parameter: :y},
108
+ {transformation: :with, parameter: {field: :x}},
109
+ {transformation: :with, parameter: {field: :y}},
110
110
  {transformation: :instance, parameter: 12},
111
111
  {transformation: :context, parameter: :context}
112
112
  ]
@@ -307,4 +307,22 @@ describe QueryInterface::Client::LazyQuery do
307
307
  end
308
308
  end
309
309
 
310
+ context "to_param" do
311
+ let(:transformations) {[]}
312
+ let(:result) { double("result") }
313
+ before do
314
+ model.should_receive(:get_raw)
315
+ .with(:query, transformations: self.transformations)
316
+ .and_return({parsed_data: {data: ["result object"]}})
317
+ model.stub(:new_collection).and_return(result)
318
+ end
319
+ it "calls to_key on the evaluated result if persisted" do
320
+ query = subject.new(model)
321
+ result.should_receive(:persisted?).and_return(true)
322
+ result.should_receive(:to_key).and_return([5])
323
+ query.to_param.should eq("5")
324
+ end
325
+
326
+ end
327
+
310
328
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: query-interface-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
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: 2014-01-30 00:00:00.000000000 Z
13
+ date: 2014-02-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: her