caprese 0.3.10 → 0.3.11

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: 035e47b3d554dfe086561c6453c06694c1efdaf3
4
- data.tar.gz: d7583109face1fcfce1ce345babd819624f6946a
3
+ metadata.gz: 0a9e6756d45e03f3c91b1c6481aec5b57032a103
4
+ data.tar.gz: 70d8e1b6c043dab986369ac84c3cf2912a44700d
5
5
  SHA512:
6
- metadata.gz: 4bd42dfd69b4a2c94b77437a1d781eee14d91dd22685293769065051fcc1d420f3a9ef560555511bab91fa6f96baab42855623020373cd99eaa4f1d94315f358
7
- data.tar.gz: 4dd5c544615bd8ad2af0a48f024da0a740f99ca81d5d5f81868cb5b0d8a3621857e3e779f9b5404226db97d9189e62339e71bdd89b838d2a0f082013865a68cb
6
+ metadata.gz: 1c144ac674470aeeabecd13910a0ec0ec3cd6ce2a3621c7c2eccc75783aeceb9f2996b2dff1b85e42ba5155db19b39307214a647a0c834a58df0edd3e3ff95a4
7
+ data.tar.gz: dd3a0c1156512e15efd759a8cc03d8d76695ff9db17a3098884939c6c42578f5cea864436a2edad6e7bb2dca46038be85d378b7dc92988e8fd91880e2ad5de84
data/CHANGELOG.md CHANGED
@@ -59,3 +59,7 @@
59
59
  ## 0.3.10
60
60
 
61
61
  * Propagate translation options on nested error to parent when validates_associated (2178fbd)
62
+
63
+ ## 0.3.11
64
+
65
+ * Allow `record_scope` and `relationship_scope` to return `[]`
@@ -102,7 +102,7 @@ module Caprese
102
102
  def get_record(scope, column, value)
103
103
  scope = record_scope(scope.to_sym) unless scope.respond_to?(:find_by)
104
104
 
105
- scope.find_by(column => value)
105
+ scope.find_by(column => value) unless scope.empty?
106
106
  end
107
107
 
108
108
  # Gets a record in a scope using a column/value to search by
@@ -113,7 +113,7 @@ module Caprese
113
113
  scope = record_scope(scope.to_sym) unless scope.respond_to?(:find_by!)
114
114
 
115
115
  begin
116
- scope.find_by!(column => value)
116
+ scope.find_by!(column => value) unless scope.is_a?(Array) && scope.empty?
117
117
  rescue ActiveRecord::RecordNotFound => e
118
118
  fail RecordNotFoundError.new(
119
119
  field: column,
@@ -128,6 +128,8 @@ module Caprese
128
128
  # @param [Relation] scope the scope to apply sorting and pagination to
129
129
  # @return [Relation] the sorted and paginated scope
130
130
  def apply_sorting_pagination_to_scope(scope)
131
+ return scope if scope.empty?
132
+
131
133
  if query_params[:sort].try(:any?)
132
134
  ordering = {}
133
135
  query_params[:sort].each do |sort_field|
@@ -1,3 +1,3 @@
1
1
  module Caprese
2
- VERSION = '0.3.10'
2
+ VERSION = '0.3.11'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caprese
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.10
4
+ version: 0.3.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Landgrebe
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2017-02-18 00:00:00.000000000 Z
13
+ date: 2017-02-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: active_model_serializers