active_cached_resource 0.1.5 → 0.1.6

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
  SHA256:
3
- metadata.gz: febe875b913adcca00b5ca5eab9c43b23691912ba4465ce34c3f842ba2c0652c
4
- data.tar.gz: 39d644336fd27dc4404c8c2d6f130b74e64686c8d923ee6c3b0257fcd1890576
3
+ metadata.gz: a7398b81424e7d34365729859220d5d05265452e4c7d8024f123b5a18f0490f0
4
+ data.tar.gz: 0c8b48b2cecec7992a5170b3467839cf7c4e9d13f141d552a9206f9eccc5527d
5
5
  SHA512:
6
- metadata.gz: 78ac473ce4a0710031fd09b9f88f713e90838b287e8361b22ef1c534f8cb9d13369ea2ab1eb78a96e47ea7cfa04bed8014157891098f92743bf4f54113292596
7
- data.tar.gz: dc3d33e8c76855b9e58eab1d258aa335f3d939688e2be0ee853a0614d901f61339204c358d866e8ec379318c0fd604e3eee2d4a3318a7d6a28cf9662bf6b2e9b
6
+ metadata.gz: ea69cc9271151a45decccb33a3e52275d05bd0dc0d4244472305e6b050479fb51431f42c13705f19a380bf0cfe1dba1e1242ff6480b4b23992fb850c25df32dd
7
+ data.tar.gz: '0807a7648e90ffd1e4a0c5650d52c15f67438a9a84366cf9a2563cd775ecd92a68f9fe0d816a8dac80f09f277623928b717a9f25f33fe1c484cb8617da367bc6'
data/CHANGELOG.md CHANGED
@@ -1,9 +1,16 @@
1
- ## [0.1.5] - 2024-01-30
1
+ ## [0.1.6] - 2024-01-15
2
+ - Renamed `ActiveResource::Collection#refresh` to `#reload` to match Rails ORM naming convention.
3
+ - Added a `ActiveResource::Collection.none` class method similar to Rails `ActiveRecord::QueryMethods.none`
4
+ - Enhanced `ActiveResource::Collection#where` so that it returns `ActiveResource::Collection.none` if `resource_class` is missing.
5
+ - This is useful for when `where` clauses are chained on an empty `ActiveResource::Collection`
6
+
7
+ ## [0.1.5] - 2024-01-09
2
8
  - Added callbacks to cache:
3
9
  - Create/POST, refresh cache after successful POST request
4
10
  - Update/PUT, refresh cache after successful PUT request
5
11
  - Destroy/DELETE, invalidate cache after successful DELETE request
6
12
  - Fixed issue with generator for SQLCache strategy tables
13
+
7
14
  ## [0.1.4] - 2024-12-20
8
15
  - CI Improvements
9
16
  - Added annotations
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveCachedResource
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.6"
5
5
  end
@@ -21,6 +21,23 @@ module ActiveResource # :nodoc:
21
21
  attr_writer :prefix_options
22
22
  attr_reader :from
23
23
 
24
+ # Returns a frozen empty collection.
25
+ #
26
+ # @return [ActiveResource::Collection] an empty collection
27
+ def self.none
28
+ new([]).tap do |collection|
29
+ collection.instance_variable_set(:@requested, true)
30
+ end
31
+ end
32
+
33
+ # Creates a new ActiveResource::Collection instance.
34
+ #
35
+ # ==== Arguments
36
+ #
37
+ # +elements+ (Array<Object>) - An optional array of resources to be set as the collection elements.
38
+ # Defaults to an empty array.
39
+ # +from+ (String, Symbol) - The path to the collection resource or the symbol for the collection resource.
40
+
24
41
  # ActiveResource::Collection is a wrapper to handle parsing index responses that
25
42
  # do not directly map to Rails conventions.
26
43
  #
@@ -98,12 +115,12 @@ module ActiveResource # :nodoc:
98
115
  @prefix_options || {}
99
116
  end
100
117
 
101
- # Refreshes the collection by re-fetching the resources from the API.
118
+ # Reload the collection by re-fetching the resources from the API.
102
119
  #
103
120
  # ==== Returns
104
121
  #
105
122
  # [Array<Object>] The collection of resources retrieved from the API.
106
- def refresh
123
+ def reload
107
124
  @requested = false
108
125
  request_resources!
109
126
  end
@@ -182,6 +199,7 @@ module ActiveResource # :nodoc:
182
199
  # # => PostCollection:xxx (filtered collection)
183
200
  def where(clauses = {})
184
201
  raise ArgumentError, "expected a clauses Hash, got #{clauses.inspect}" unless clauses.is_a? Hash
202
+ return self.class.none if resource_class.nil?
185
203
  new_clauses = query_params.merge(clauses)
186
204
  resource_class.where(new_clauses)
187
205
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_cached_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Luis Urena
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-01-09 00:00:00.000000000 Z
10
+ date: 2025-01-15 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activemodel-serializers-xml
@@ -71,6 +71,20 @@ dependencies:
71
71
  - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: 1.7.5
74
+ - !ruby/object:Gem::Dependency
75
+ name: ostruct
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: 0.6.1
81
+ type: :runtime
82
+ prerelease: false
83
+ version_requirements: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: 0.6.1
74
88
  email:
75
89
  - eljean@live.com
76
90
  executables: []