haveapi 0.5.2 → 0.5.3

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: 8579fbd8dd467b3248bba5d3cd8cbb46c889621b
4
- data.tar.gz: 12fa89e290d89ea301123f66ca86e6bfc19c4785
3
+ metadata.gz: f07a08da63c6a6971d962f5de898151b8f1526e8
4
+ data.tar.gz: 82a118d577b0f0c21585282b6e72733e8dac8857
5
5
  SHA512:
6
- metadata.gz: f406e97a08f0ae4c4b0fb6dab2114a36208f8ef6190f5480b9a86765dc97005ddf866402674164ae96d36f989e6ea40ed5f6e2e75d56a442751cf2e4e9613c0f
7
- data.tar.gz: 2f5d0ebae55c055ac725097260b2fecbea6903b74d7927fc723186e6bacf708376a6cce978bea15c6594c44302e6d7547bc226f8a46f5d863417a9d7cc989a8c
6
+ metadata.gz: babc460201bfb5cff7adfab5017a70570f69c0b484e898b3ca62c2d1c016a1cde2c93c2369edadfc0de2c9ec1a8a392b89c2eb1288863b938fb551e411d54850
7
+ data.tar.gz: 8f1bea4fc43b85ff52374ac37cab28af42e7a1be75210fafe458f84a6a6f0503495f0b2921596c50b221430150362a33afc63f1a200ab2def908f236db482891
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ * Mon Apr 18 2016 - version 0.5.3
2
+ - ActiveRecord.ar_parse_includes: ignore not existing associations
3
+ - Paginable: remove default values for limit and offset parameters
4
+
1
5
  * Thu Mar 03 2016 - version 0.5.2
2
6
  - Fix ActiveRecord dependency
3
7
  - Require json
data/haveapi.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'haveapi/version'
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'haveapi'
7
7
  s.version = HaveAPI::VERSION
8
- s.date = '2016-03-03'
8
+ s.date = '2016-04-18'
9
9
  s.summary =
10
10
  s.description = 'Framework for creating self-describing APIs'
11
11
  s.authors = 'Jakub Skokan'
@@ -2,11 +2,9 @@ module HaveAPI::Actions
2
2
  module Paginable
3
3
  def self.included(action)
4
4
  action.input do
5
- integer :offset, label: 'Offset', desc: 'The offset of the first object',
6
- default: 0
7
- integer :limit, label: 'Limit', desc: 'The number of objects to retrieve',
8
- default: 25
5
+ integer :offset, label: 'Offset', desc: 'The offset of the first object'
6
+ integer :limit, label: 'Limit', desc: 'The number of objects to retrieve'
9
7
  end
10
8
  end
11
9
  end
12
- end
10
+ end
@@ -43,7 +43,21 @@ module HaveAPI::ModelAdapters
43
43
  # in an array of symbols and hashes.
44
44
  def ar_parse_includes(raw)
45
45
  return @ar_parsed_includes if @ar_parsed_includes
46
- @ar_parsed_includes = ar_inner_includes(raw)
46
+ @ar_parsed_includes = ar_inner_includes(raw).select do |inc|
47
+ # Drop associations that are not registered in the AR:
48
+ # The API resource may have associations that are not based on
49
+ # associations in AR.
50
+ if inc.is_a?(::Hash)
51
+ inc.each_key do |k|
52
+ next(false) unless self.class.model.reflections.has_key?(k)
53
+ end
54
+
55
+ else
56
+ next(false) unless self.class.model.reflections.has_key?(inc)
57
+ end
58
+
59
+ true
60
+ end
47
61
  end
48
62
 
49
63
  # Called by ar_parse_includes for recursion purposes.
@@ -1,4 +1,4 @@
1
1
  module HaveAPI
2
2
  PROTOCOL_VERSION = '1.0'
3
- VERSION = '0.5.2'
3
+ VERSION = '0.5.3'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haveapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakub Skokan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-03 00:00:00.000000000 Z
11
+ date: 2016-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: require_all