active_cached_resource 0.0.1.pre → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/LICENSE +21 -0
- data/lib/active_cached_resource/caching.rb +104 -1
- data/lib/active_cached_resource/configuration.rb +22 -1
- data/lib/active_cached_resource/logger.rb +14 -0
- data/lib/active_cached_resource/model.rb +18 -0
- data/lib/active_cached_resource/version.rb +1 -8
- data/lib/activeresource/lib/active_resource/collection.rb +14 -1
- data/lib/activeresource/lib/active_resource/railtie.rb +2 -2
- data/lib/activeresource/lib/active_resource.rb +1 -1
- metadata +5 -401
- data/.rspec +0 -3
- data/.rubocop.yml +0 -22
- data/.standard.yml +0 -2
- data/Rakefile +0 -21
- data/example/consumer/.dockerignore +0 -41
- data/example/consumer/.gitattributes +0 -9
- data/example/consumer/.gitignore +0 -36
- data/example/consumer/.kamal/hooks/docker-setup.sample +0 -3
- data/example/consumer/.kamal/hooks/post-deploy.sample +0 -14
- data/example/consumer/.kamal/hooks/post-proxy-reboot.sample +0 -3
- data/example/consumer/.kamal/hooks/pre-build.sample +0 -51
- data/example/consumer/.kamal/hooks/pre-connect.sample +0 -47
- data/example/consumer/.kamal/hooks/pre-deploy.sample +0 -109
- data/example/consumer/.kamal/hooks/pre-proxy-reboot.sample +0 -3
- data/example/consumer/.kamal/secrets +0 -17
- data/example/consumer/Dockerfile +0 -65
- data/example/consumer/Gemfile +0 -17
- data/example/consumer/Rakefile +0 -6
- data/example/consumer/app/controllers/application_controller.rb +0 -2
- data/example/consumer/app/controllers/concerns/.keep +0 -0
- data/example/consumer/app/jobs/application_job.rb +0 -7
- data/example/consumer/app/mailers/application_mailer.rb +0 -4
- data/example/consumer/app/models/application_record.rb +0 -3
- data/example/consumer/app/models/concerns/.keep +0 -0
- data/example/consumer/app/models/person.rb +0 -9
- data/example/consumer/app/views/layouts/mailer.html.erb +0 -13
- data/example/consumer/app/views/layouts/mailer.text.erb +0 -1
- data/example/consumer/bin/brakeman +0 -7
- data/example/consumer/bin/bundle +0 -109
- data/example/consumer/bin/dev +0 -2
- data/example/consumer/bin/docker-entrypoint +0 -14
- data/example/consumer/bin/jobs +0 -6
- data/example/consumer/bin/kamal +0 -27
- data/example/consumer/bin/rails +0 -4
- data/example/consumer/bin/rake +0 -4
- data/example/consumer/bin/rubocop +0 -8
- data/example/consumer/bin/setup +0 -34
- data/example/consumer/bin/thrust +0 -5
- data/example/consumer/config/application.rb +0 -20
- data/example/consumer/config/boot.rb +0 -3
- data/example/consumer/config/cache.yml +0 -16
- data/example/consumer/config/credentials.yml.enc +0 -1
- data/example/consumer/config/database.yml +0 -14
- data/example/consumer/config/deploy.yml +0 -116
- data/example/consumer/config/environment.rb +0 -5
- data/example/consumer/config/environments/development.rb +0 -64
- data/example/consumer/config/environments/production.rb +0 -85
- data/example/consumer/config/environments/test.rb +0 -50
- data/example/consumer/config/initializers/cors.rb +0 -16
- data/example/consumer/config/initializers/filter_parameter_logging.rb +0 -8
- data/example/consumer/config/initializers/inflections.rb +0 -16
- data/example/consumer/config/locales/en.yml +0 -31
- data/example/consumer/config/puma.rb +0 -41
- data/example/consumer/config/queue.yml +0 -18
- data/example/consumer/config/recurring.yml +0 -10
- data/example/consumer/config/routes.rb +0 -10
- data/example/consumer/config.ru +0 -6
- data/example/consumer/db/cache_schema.rb +0 -14
- data/example/consumer/db/queue_schema.rb +0 -129
- data/example/consumer/db/seeds.rb +0 -0
- data/example/consumer/lib/tasks/.keep +0 -0
- data/example/consumer/log/.keep +0 -0
- data/example/consumer/public/robots.txt +0 -1
- data/example/consumer/script/.keep +0 -0
- data/example/consumer/storage/.keep +0 -0
- data/example/consumer/tmp/.keep +0 -0
- data/example/consumer/tmp/cache/.keep +0 -0
- data/example/consumer/tmp/pids/.keep +0 -0
- data/example/consumer/tmp/storage/.keep +0 -0
- data/example/consumer/vendor/.keep +0 -0
- data/example/provider/.dockerignore +0 -41
- data/example/provider/.gitattributes +0 -9
- data/example/provider/.gitignore +0 -32
- data/example/provider/.kamal/hooks/docker-setup.sample +0 -3
- data/example/provider/.kamal/hooks/post-deploy.sample +0 -14
- data/example/provider/.kamal/hooks/post-proxy-reboot.sample +0 -3
- data/example/provider/.kamal/hooks/pre-build.sample +0 -51
- data/example/provider/.kamal/hooks/pre-connect.sample +0 -47
- data/example/provider/.kamal/hooks/pre-deploy.sample +0 -109
- data/example/provider/.kamal/hooks/pre-proxy-reboot.sample +0 -3
- data/example/provider/.kamal/secrets +0 -17
- data/example/provider/Dockerfile +0 -65
- data/example/provider/Gemfile +0 -14
- data/example/provider/Rakefile +0 -6
- data/example/provider/app/controllers/application_controller.rb +0 -2
- data/example/provider/app/controllers/concerns/.keep +0 -0
- data/example/provider/app/controllers/people_controller.rb +0 -68
- data/example/provider/app/jobs/application_job.rb +0 -7
- data/example/provider/app/mailers/application_mailer.rb +0 -4
- data/example/provider/app/models/address.rb +0 -3
- data/example/provider/app/models/application_record.rb +0 -3
- data/example/provider/app/models/company.rb +0 -3
- data/example/provider/app/models/concerns/.keep +0 -0
- data/example/provider/app/models/person.rb +0 -6
- data/example/provider/app/views/layouts/mailer.html.erb +0 -13
- data/example/provider/app/views/layouts/mailer.text.erb +0 -1
- data/example/provider/bin/brakeman +0 -7
- data/example/provider/bin/bundle +0 -109
- data/example/provider/bin/dev +0 -2
- data/example/provider/bin/docker-entrypoint +0 -14
- data/example/provider/bin/jobs +0 -6
- data/example/provider/bin/kamal +0 -27
- data/example/provider/bin/rails +0 -4
- data/example/provider/bin/rake +0 -4
- data/example/provider/bin/rubocop +0 -8
- data/example/provider/bin/setup +0 -34
- data/example/provider/bin/thrust +0 -5
- data/example/provider/config/application.rb +0 -44
- data/example/provider/config/boot.rb +0 -3
- data/example/provider/config/cache.yml +0 -16
- data/example/provider/config/credentials.yml.enc +0 -1
- data/example/provider/config/database.yml +0 -20
- data/example/provider/config/deploy.yml +0 -116
- data/example/provider/config/environment.rb +0 -5
- data/example/provider/config/environments/development.rb +0 -64
- data/example/provider/config/environments/production.rb +0 -85
- data/example/provider/config/environments/test.rb +0 -50
- data/example/provider/config/initializers/cors.rb +0 -16
- data/example/provider/config/initializers/filter_parameter_logging.rb +0 -8
- data/example/provider/config/initializers/inflections.rb +0 -16
- data/example/provider/config/locales/en.yml +0 -31
- data/example/provider/config/puma.rb +0 -41
- data/example/provider/config/queue.yml +0 -18
- data/example/provider/config/recurring.yml +0 -10
- data/example/provider/config/routes.rb +0 -4
- data/example/provider/config.ru +0 -6
- data/example/provider/db/cache_schema.rb +0 -14
- data/example/provider/db/migrate/20241202183937_create_people.rb +0 -11
- data/example/provider/db/migrate/20241202183955_create_addresses.rb +0 -13
- data/example/provider/db/migrate/20241202184017_create_companies.rb +0 -14
- data/example/provider/db/queue_schema.rb +0 -129
- data/example/provider/db/schema.rb +0 -47
- data/example/provider/db/seeds.rb +0 -18
- data/example/provider/lib/tasks/.keep +0 -0
- data/example/provider/log/.keep +0 -0
- data/example/provider/public/robots.txt +0 -1
- data/example/provider/script/.keep +0 -0
- data/example/provider/storage/.keep +0 -0
- data/example/provider/tmp/.keep +0 -0
- data/example/provider/tmp/pids/.keep +0 -0
- data/example/provider/tmp/storage/.keep +0 -0
- data/example/provider/vendor/.keep +0 -0
- data/lib/activeresource/.gitignore +0 -15
- data/lib/activeresource/examples/performance.rb +0 -72
- data/lib/activeresource/test/abstract_unit.rb +0 -153
- data/lib/activeresource/test/cases/active_job_serializer_test.rb +0 -53
- data/lib/activeresource/test/cases/association_test.rb +0 -104
- data/lib/activeresource/test/cases/associations/builder/belongs_to_test.rb +0 -42
- data/lib/activeresource/test/cases/associations/builder/has_many_test.rb +0 -28
- data/lib/activeresource/test/cases/associations/builder/has_one_test.rb +0 -28
- data/lib/activeresource/test/cases/authorization_test.rb +0 -276
- data/lib/activeresource/test/cases/base/custom_methods_test.rb +0 -155
- data/lib/activeresource/test/cases/base/equality_test.rb +0 -53
- data/lib/activeresource/test/cases/base/load_test.rb +0 -249
- data/lib/activeresource/test/cases/base/schema_test.rb +0 -428
- data/lib/activeresource/test/cases/base_errors_test.rb +0 -129
- data/lib/activeresource/test/cases/base_test.rb +0 -1622
- data/lib/activeresource/test/cases/callbacks_test.rb +0 -155
- data/lib/activeresource/test/cases/collection_test.rb +0 -172
- data/lib/activeresource/test/cases/connection_test.rb +0 -357
- data/lib/activeresource/test/cases/finder_test.rb +0 -217
- data/lib/activeresource/test/cases/format_test.rb +0 -137
- data/lib/activeresource/test/cases/http_mock_test.rb +0 -213
- data/lib/activeresource/test/cases/inheritence_test.rb +0 -19
- data/lib/activeresource/test/cases/inheriting_hash_test.rb +0 -25
- data/lib/activeresource/test/cases/log_subscriber_test.rb +0 -63
- data/lib/activeresource/test/cases/reflection_test.rb +0 -65
- data/lib/activeresource/test/cases/validations_test.rb +0 -78
- data/lib/activeresource/test/fixtures/address.rb +0 -20
- data/lib/activeresource/test/fixtures/beast.rb +0 -16
- data/lib/activeresource/test/fixtures/comment.rb +0 -5
- data/lib/activeresource/test/fixtures/customer.rb +0 -5
- data/lib/activeresource/test/fixtures/inventory.rb +0 -14
- data/lib/activeresource/test/fixtures/person.rb +0 -15
- data/lib/activeresource/test/fixtures/pet.rb +0 -6
- data/lib/activeresource/test/fixtures/post.rb +0 -5
- data/lib/activeresource/test/fixtures/product.rb +0 -11
- data/lib/activeresource/test/fixtures/project.rb +0 -19
- data/lib/activeresource/test/fixtures/proxy.rb +0 -6
- data/lib/activeresource/test/fixtures/sound.rb +0 -11
- data/lib/activeresource/test/fixtures/street_address.rb +0 -6
- data/lib/activeresource/test/fixtures/subscription_plan.rb +0 -7
- data/lib/activeresource/test/fixtures/weather.rb +0 -21
- data/lib/activeresource/test/setter_trap.rb +0 -28
- data/lib/activeresource/test/singleton_test.rb +0 -138
- data/lib/activeresource/test/threadsafe_attributes_test.rb +0 -91
- data/sorbet/config +0 -4
- data/sorbet/rbi/annotations/.gitattributes +0 -1
- data/sorbet/rbi/annotations/activemodel.rbi +0 -89
- data/sorbet/rbi/annotations/activesupport.rbi +0 -457
- data/sorbet/rbi/annotations/minitest.rbi +0 -119
- data/sorbet/rbi/annotations/rainbow.rbi +0 -269
- data/sorbet/rbi/dsl/.gitattributes +0 -1
- data/sorbet/rbi/dsl/active_support/callbacks.rbi +0 -21
- data/sorbet/rbi/gems/.gitattributes +0 -1
- data/sorbet/rbi/gems/actioncable@8.0.0.rbi +0 -252
- data/sorbet/rbi/gems/actionmailbox@8.0.0.rbi +0 -9
- data/sorbet/rbi/gems/actionmailer@8.0.0.rbi +0 -9
- data/sorbet/rbi/gems/actionpack@8.0.0.rbi +0 -20909
- data/sorbet/rbi/gems/actiontext@8.0.0.rbi +0 -9
- data/sorbet/rbi/gems/actionview@8.0.0.rbi +0 -16207
- data/sorbet/rbi/gems/activejob@8.0.0.rbi +0 -9
- data/sorbet/rbi/gems/activemodel-serializers-xml@1.0.3.rbi +0 -166
- data/sorbet/rbi/gems/activemodel@8.0.0.rbi +0 -6857
- data/sorbet/rbi/gems/activerecord@8.0.0.rbi +0 -42896
- data/sorbet/rbi/gems/activeresource@6.1.4.rbi +0 -3944
- data/sorbet/rbi/gems/activestorage@8.0.0.rbi +0 -9
- data/sorbet/rbi/gems/activesupport@8.0.0.rbi +0 -21251
- data/sorbet/rbi/gems/ast@2.4.2.rbi +0 -585
- data/sorbet/rbi/gems/base64@0.2.0.rbi +0 -509
- data/sorbet/rbi/gems/benchmark@0.4.0.rbi +0 -618
- data/sorbet/rbi/gems/bigdecimal@3.1.8.rbi +0 -78
- data/sorbet/rbi/gems/builder@3.3.0.rbi +0 -9
- data/sorbet/rbi/gems/bump@0.10.0.rbi +0 -169
- data/sorbet/rbi/gems/byebug@11.1.3.rbi +0 -3607
- data/sorbet/rbi/gems/coderay@1.1.3.rbi +0 -3427
- data/sorbet/rbi/gems/concurrent-ruby@1.3.4.rbi +0 -11645
- data/sorbet/rbi/gems/connection_pool@2.4.1.rbi +0 -9
- data/sorbet/rbi/gems/crass@1.0.6.rbi +0 -623
- data/sorbet/rbi/gems/date@3.4.0.rbi +0 -75
- data/sorbet/rbi/gems/diff-lcs@1.5.1.rbi +0 -1131
- data/sorbet/rbi/gems/docile@1.4.1.rbi +0 -377
- data/sorbet/rbi/gems/drb@2.2.1.rbi +0 -1347
- data/sorbet/rbi/gems/erubi@1.13.0.rbi +0 -150
- data/sorbet/rbi/gems/globalid@1.2.1.rbi +0 -9
- data/sorbet/rbi/gems/i18n@1.14.6.rbi +0 -2359
- data/sorbet/rbi/gems/io-console@0.7.2.rbi +0 -9
- data/sorbet/rbi/gems/json@2.8.2.rbi +0 -1901
- data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +0 -14238
- data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +0 -240
- data/sorbet/rbi/gems/logger@1.6.1.rbi +0 -920
- data/sorbet/rbi/gems/loofah@2.23.1.rbi +0 -1081
- data/sorbet/rbi/gems/mail@2.8.1.rbi +0 -9
- data/sorbet/rbi/gems/marcel@1.0.4.rbi +0 -9
- data/sorbet/rbi/gems/method_source@1.1.0.rbi +0 -304
- data/sorbet/rbi/gems/mini_mime@1.1.5.rbi +0 -9
- data/sorbet/rbi/gems/minitest@5.25.2.rbi +0 -1547
- data/sorbet/rbi/gems/net-imap@0.5.1.rbi +0 -9
- data/sorbet/rbi/gems/net-pop@0.1.2.rbi +0 -9
- data/sorbet/rbi/gems/net-protocol@0.2.2.rbi +0 -292
- data/sorbet/rbi/gems/net-smtp@0.5.0.rbi +0 -9
- data/sorbet/rbi/gems/netrc@0.11.0.rbi +0 -159
- data/sorbet/rbi/gems/nio4r@2.7.4.rbi +0 -9
- data/sorbet/rbi/gems/nokogiri@1.16.7.rbi +0 -7311
- data/sorbet/rbi/gems/parallel@1.26.3.rbi +0 -291
- data/sorbet/rbi/gems/parser@3.3.6.0.rbi +0 -5519
- data/sorbet/rbi/gems/prism@1.2.0.rbi +0 -39085
- data/sorbet/rbi/gems/pry-byebug@3.10.1.rbi +0 -1151
- data/sorbet/rbi/gems/pry@0.14.2.rbi +0 -10076
- data/sorbet/rbi/gems/psych@5.2.0.rbi +0 -1785
- data/sorbet/rbi/gems/racc@1.8.1.rbi +0 -162
- data/sorbet/rbi/gems/rack-session@2.0.0.rbi +0 -727
- data/sorbet/rbi/gems/rack-test@2.1.0.rbi +0 -747
- data/sorbet/rbi/gems/rack@3.1.8.rbi +0 -4905
- data/sorbet/rbi/gems/rackup@2.2.1.rbi +0 -230
- data/sorbet/rbi/gems/rails-dom-testing@2.2.0.rbi +0 -758
- data/sorbet/rbi/gems/rails-html-sanitizer@1.6.0.rbi +0 -785
- data/sorbet/rbi/gems/rails@8.0.0.rbi +0 -9
- data/sorbet/rbi/gems/railties@8.0.0.rbi +0 -6287
- data/sorbet/rbi/gems/rainbow@3.1.1.rbi +0 -403
- data/sorbet/rbi/gems/rake@13.2.1.rbi +0 -3091
- data/sorbet/rbi/gems/rbi@0.2.1.rbi +0 -4535
- data/sorbet/rbi/gems/rdoc@6.8.1.rbi +0 -12572
- data/sorbet/rbi/gems/regexp_parser@2.9.2.rbi +0 -3772
- data/sorbet/rbi/gems/reline@0.5.12.rbi +0 -2416
- data/sorbet/rbi/gems/rexml@3.3.9.rbi +0 -4858
- data/sorbet/rbi/gems/rspec-core@3.13.2.rbi +0 -11287
- data/sorbet/rbi/gems/rspec-expectations@3.13.3.rbi +0 -8183
- data/sorbet/rbi/gems/rspec-mocks@3.13.2.rbi +0 -5341
- data/sorbet/rbi/gems/rspec-support@3.13.1.rbi +0 -1630
- data/sorbet/rbi/gems/rspec@3.13.0.rbi +0 -83
- data/sorbet/rbi/gems/rubocop-ast@1.36.1.rbi +0 -7303
- data/sorbet/rbi/gems/rubocop-performance@1.21.1.rbi +0 -9
- data/sorbet/rbi/gems/rubocop@1.65.1.rbi +0 -58170
- data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +0 -1318
- data/sorbet/rbi/gems/securerandom@0.3.2.rbi +0 -395
- data/sorbet/rbi/gems/simplecov-html@0.13.1.rbi +0 -225
- data/sorbet/rbi/gems/simplecov@0.22.0.rbi +0 -2149
- data/sorbet/rbi/gems/simplecov_json_formatter@0.1.4.rbi +0 -9
- data/sorbet/rbi/gems/spoom@1.5.0.rbi +0 -4932
- data/sorbet/rbi/gems/standard-custom@1.0.2.rbi +0 -9
- data/sorbet/rbi/gems/standard-performance@1.4.0.rbi +0 -9
- data/sorbet/rbi/gems/standard@1.40.0.rbi +0 -929
- data/sorbet/rbi/gems/stringio@3.1.2.rbi +0 -9
- data/sorbet/rbi/gems/tapioca@0.16.4.rbi +0 -3597
- data/sorbet/rbi/gems/thor@1.3.2.rbi +0 -4378
- data/sorbet/rbi/gems/timeout@0.4.2.rbi +0 -151
- data/sorbet/rbi/gems/tzinfo@2.0.6.rbi +0 -5918
- data/sorbet/rbi/gems/unicode-display_width@2.6.0.rbi +0 -66
- data/sorbet/rbi/gems/uri@1.0.2.rbi +0 -2377
- data/sorbet/rbi/gems/useragent@0.16.10.rbi +0 -9
- data/sorbet/rbi/gems/websocket-driver@0.7.6.rbi +0 -9
- data/sorbet/rbi/gems/websocket-extensions@0.1.5.rbi +0 -9
- data/sorbet/rbi/gems/yard-sorbet@0.9.0.rbi +0 -435
- data/sorbet/rbi/gems/yard@0.9.37.rbi +0 -18504
- data/sorbet/rbi/gems/zeitwerk@2.7.1.rbi +0 -9
- data/sorbet/tapioca/config.yml +0 -13
- data/sorbet/tapioca/require.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fbe9addf18997d8c80d81b8660cc87b5da170816bdfa5015d905478ee1b92d4
|
4
|
+
data.tar.gz: 5e01c4a110ee3727a66ae1474bdd2757436f0042579f2207bd0e0d6e19a57e5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a33b4446dfdf4aa9feba9b603382f08d1367035a1cb0e2a1387d54b695524084c56d1f57a98f79e77d18284268d06a2d2654a2972b8e4b2415c5314fb632122
|
7
|
+
data.tar.gz: 19e006d900db205641c937a415e989eeb08a74063a126d1caa53d14bf6746399a887f67a116494b839704f3728d0a989e57e67bd59aff568256e253528e5d420
|
data/CHANGELOG.md
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) [2024] [Jean Luis Urena]
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -13,6 +13,105 @@ module ActiveCachedResource
|
|
13
13
|
end
|
14
14
|
|
15
15
|
module ClassMethods
|
16
|
+
# Finds resources similarly to ActiveRecord's +find+ method, with caching support.
|
17
|
+
#
|
18
|
+
# This method is also called internally by the `where` method. When you use `where` to filter results,
|
19
|
+
# it translates the query conditions into parameters and delegates to this method.
|
20
|
+
#
|
21
|
+
# Depending on the first argument provided, this method retrieves:
|
22
|
+
#
|
23
|
+
# * `:one` - A single resource.
|
24
|
+
# * `:first` - The first resource in the result set.
|
25
|
+
# * `:last` - The last resource in the result set.
|
26
|
+
# * `:all` - An array of all matching resources.
|
27
|
+
#
|
28
|
+
# If an Integer or String ID is provided instead of a symbol, it attempts to find a single resource by that ID.
|
29
|
+
#
|
30
|
+
# @overload find_with_cache(scope, options = {})
|
31
|
+
# @param scope [Symbol, Integer, String]
|
32
|
+
# The scope of the query or the ID of the resource to find.
|
33
|
+
# Can be `:one`, `:first`, `:last`, `:all`, or a specific ID.
|
34
|
+
# @param options [Hash] Additional query options.
|
35
|
+
# @option options [String, Symbol] :from
|
36
|
+
# The path or custom endpoint from which to fetch resources.
|
37
|
+
# @option options [Hash] :params
|
38
|
+
# Query and prefix (nested URL) parameters.
|
39
|
+
#
|
40
|
+
# @return [Object, Array<Object>, nil]
|
41
|
+
# * Returns a single resource object if `:one`, `:first`, `:last`, or an ID is given.
|
42
|
+
# * Returns an array of resources if `:all` is given.
|
43
|
+
# * Returns `nil` if no data is found for `:one`, `:first`, `:last`, or `:all` queries.
|
44
|
+
#
|
45
|
+
# @raise [ResourceNotFound]
|
46
|
+
# Raises if the requested resource by ID cannot be found.
|
47
|
+
#
|
48
|
+
# @note
|
49
|
+
# If the `:reload` option is passed (e.g. `:reload => true`), the cache will be bypassed, and
|
50
|
+
# the resource(s) will be fetched directly from the server.
|
51
|
+
#
|
52
|
+
# @example Find a single resource by ID
|
53
|
+
# Person.find(1)
|
54
|
+
# # GET /people/1.json
|
55
|
+
#
|
56
|
+
# @example Find all resources
|
57
|
+
# Person.find(:all)
|
58
|
+
# # GET /people.json
|
59
|
+
#
|
60
|
+
# @example Find all resources with query parameters
|
61
|
+
# Person.find(:all, params: { title: "CEO" })
|
62
|
+
# # GET /people.json?title=CEO
|
63
|
+
#
|
64
|
+
# @example Find the first resource from a custom endpoint
|
65
|
+
# Person.find(:first, from: :managers)
|
66
|
+
# # GET /people/managers.json
|
67
|
+
#
|
68
|
+
# @example Find the last resource from a custom endpoint
|
69
|
+
# Person.find(:last, from: :managers)
|
70
|
+
# # GET /people/managers.json
|
71
|
+
#
|
72
|
+
# @example Find all resources from a nested URL
|
73
|
+
# Person.find(:all, from: "/companies/1/people.json")
|
74
|
+
# # GET /companies/1/people.json
|
75
|
+
#
|
76
|
+
# @example Find a single resource from a custom endpoint
|
77
|
+
# Person.find(:one, from: :leader)
|
78
|
+
# # GET /people/leader.json
|
79
|
+
#
|
80
|
+
# @example Find all developers speaking Ruby
|
81
|
+
# Person.find(:all, from: :developers, params: { language: 'ruby' })
|
82
|
+
# # GET /people/developers.json?language=ruby
|
83
|
+
#
|
84
|
+
# @example Find a single resource from a nested URL
|
85
|
+
# Person.find(:one, from: "/companies/1/manager.json")
|
86
|
+
# # GET /companies/1/manager.json
|
87
|
+
#
|
88
|
+
# @example Find a resource with nested prefix parameters
|
89
|
+
# StreetAddress.find(1, params: { person_id: 1 })
|
90
|
+
# # GET /people/1/street_addresses/1.json
|
91
|
+
#
|
92
|
+
# When `where` is used, it automatically builds the query parameters and calls `find_with_cache(:all, ...)`:
|
93
|
+
#
|
94
|
+
# @example Using `where` with parameters
|
95
|
+
# Person.where(title: "CEO")
|
96
|
+
# # Under the hood: Person.find_with_cache(:all, params: { title: "CEO" })
|
97
|
+
# # => GET /people.json?title=CEO
|
98
|
+
#
|
99
|
+
# Person.where(language: 'ruby').where(from: :developers)
|
100
|
+
# # Under the hood: Person.find_with_cache(:all, from: :developers, params: { language: 'ruby' })
|
101
|
+
# # => GET /people/developers.json?language=ruby
|
102
|
+
#
|
103
|
+
# == Failure or missing data
|
104
|
+
# A failure to find the requested object by ID raises a ResourceNotFound exception.
|
105
|
+
# With any other scope, find returns nil when no data is returned.
|
106
|
+
#
|
107
|
+
# Person.find(1)
|
108
|
+
# # => raises ResourceNotFound
|
109
|
+
#
|
110
|
+
# Person.find(:all)
|
111
|
+
# Person.find(:first)
|
112
|
+
# Person.find(:last)
|
113
|
+
# # => nil
|
114
|
+
#
|
16
115
|
def find_with_cache(*orig_args)
|
17
116
|
args = orig_args.deep_dup # Avoid mutating original arguments
|
18
117
|
options = extract_options(*args)
|
@@ -35,7 +134,11 @@ module ActiveCachedResource
|
|
35
134
|
should_reload ? find_via_reload(*args) : find_via_cache(*args)
|
36
135
|
end
|
37
136
|
|
38
|
-
#
|
137
|
+
# Clears all cache matching the cache key prefix of the model.
|
138
|
+
#
|
139
|
+
# This method clears all cached entries that match the cache key prefix.
|
140
|
+
#
|
141
|
+
# @return [void]
|
39
142
|
def clear
|
40
143
|
cached_resource.cache.clear("#{cache_key_prefix}/")
|
41
144
|
end
|
@@ -8,11 +8,26 @@ module ActiveCachedResource
|
|
8
8
|
class Configuration < OpenStruct
|
9
9
|
CACHING_STRATEGIES = {
|
10
10
|
active_record: ActiveCachedResource::CachingStrategies::SQLCache,
|
11
|
-
|
11
|
+
active_support_cache: ActiveCachedResource::CachingStrategies::ActiveSupportCache
|
12
12
|
}
|
13
13
|
|
14
14
|
OPTIONS = %i[cache_key_prefix logger enabled ttl]
|
15
15
|
|
16
|
+
# Initializes a new configuration for the given model with the specified options.
|
17
|
+
#
|
18
|
+
# @param model [Class] The model class for which the configuration is being set.
|
19
|
+
# @param options [Hash] A hash of options to customize the configuration.
|
20
|
+
# @option options [Symbol] :cache_store The cache store to be used.
|
21
|
+
# @option options [Symbol] :cache_strategy The cache strategy to be used. One of :active_record or :active_support_cache.
|
22
|
+
# @option options [String] :cache_key_prefix The prefix for cache keys (default: model name underscored).
|
23
|
+
# @option options [Logger] :logger The logger instance to be used (default: ActiveCachedResource::Logger).
|
24
|
+
# @option options [Boolean] :enabled Whether caching is enabled (default: true).
|
25
|
+
# @option options [Integer] :ttl The time-to-live for cache entries in seconds (default: 86400).
|
26
|
+
#
|
27
|
+
# @return [ActiveCachedResource::Configuration] The configuration instance.
|
28
|
+
#
|
29
|
+
# @note If `cache_store` is provided and is a CachingStrategies::Base instance, it will be used as the cache strategy.
|
30
|
+
# Otherwise, `cache_strategy` must be provided to determine the cache strategy.
|
16
31
|
def initialize(model, options = {})
|
17
32
|
super(
|
18
33
|
{
|
@@ -25,10 +40,16 @@ module ActiveCachedResource
|
|
25
40
|
)
|
26
41
|
end
|
27
42
|
|
43
|
+
# Enables caching.
|
44
|
+
#
|
45
|
+
# @return [void]
|
28
46
|
def on!
|
29
47
|
self.enabled = true
|
30
48
|
end
|
31
49
|
|
50
|
+
# Disables caching.
|
51
|
+
#
|
52
|
+
# @return [void]
|
32
53
|
def off!
|
33
54
|
self.enabled = false
|
34
55
|
end
|
@@ -2,6 +2,15 @@ require "logger"
|
|
2
2
|
|
3
3
|
module ActiveCachedResource
|
4
4
|
class Logger < ::Logger
|
5
|
+
# @!constant COLORS
|
6
|
+
# @return [Hash] A hash that maps log levels to their corresponding ANSI color codes.
|
7
|
+
# @example
|
8
|
+
# COLORS[:debug] # => "\e[36m" (Blue)
|
9
|
+
# COLORS[:info] # => "\e[0m" (Default)
|
10
|
+
# COLORS[:warn] # => "\e[33m" (Yellow)
|
11
|
+
# COLORS[:error] # => "\e[31m" (Red)
|
12
|
+
# COLORS[:fatal] # => "\e[31m" (Red)
|
13
|
+
# COLORS[:reset] # => "\e[0m" (Reset)
|
5
14
|
COLORS = {
|
6
15
|
debug: "\e[36m", # Blue
|
7
16
|
info: "\e[0m", # Default
|
@@ -11,6 +20,11 @@ module ActiveCachedResource
|
|
11
20
|
reset: "\e[0m" # Reset
|
12
21
|
}
|
13
22
|
|
23
|
+
# Initializes a new logger instance for the specified model.
|
24
|
+
#
|
25
|
+
# @param model_name [String] the name of the model to be logged
|
26
|
+
#
|
27
|
+
# @return [void]
|
14
28
|
def initialize(model_name)
|
15
29
|
super($stdout)
|
16
30
|
@model_name = model_name
|
@@ -11,23 +11,41 @@ module ActiveCachedResource
|
|
11
11
|
class << self
|
12
12
|
attr_accessor :cached_resource
|
13
13
|
|
14
|
+
# Sets up caching for an ActiveResource model.
|
15
|
+
#
|
16
|
+
# @param options [Hash] A hash of options to customize the configuration.
|
17
|
+
# @option options [Symbol] :cache_store The cache store to be used. Must be a CachingStrategies::Base instance.
|
18
|
+
# @option options [Symbol] :cache_strategy The cache strategy to be used. One of :active_record or :active_support_cache.
|
19
|
+
# @option options [String] :cache_key_prefix The prefix for cache keys (default: model name underscored).
|
20
|
+
# @option options [Logger] :logger The logger instance to be used (default: ActiveCachedResource::Logger).
|
21
|
+
# @option options [Boolean] :enabled Whether caching is enabled (default: true).
|
22
|
+
# @option options [Integer] :ttl The time-to-live for cache entries in seconds (default: 86400).
|
23
|
+
#
|
24
|
+
# @return [ActiveCachedResource::Configuration] The configuration instance.
|
25
|
+
#
|
26
|
+
# @note If `cache_store` is provided and is a CachingStrategies::Base instance, it will be used as the cache strategy.
|
27
|
+
# Otherwise, `cache_strategy` must be provided to determine the cache strategy.
|
14
28
|
def cached_resource(options = {})
|
15
29
|
@cached_resource || setup_cached_resource!(options)
|
16
30
|
end
|
17
31
|
|
32
|
+
# :nodoc:
|
18
33
|
def setup_cached_resource!(options)
|
19
34
|
@cached_resource = ActiveCachedResource::Configuration.new(self, options)
|
20
35
|
include ActiveCachedResource::Caching
|
21
36
|
@cached_resource
|
22
37
|
end
|
38
|
+
# :nodoc:
|
23
39
|
end
|
24
40
|
end
|
25
41
|
|
42
|
+
# :nodoc:
|
26
43
|
module ClassMethods
|
27
44
|
def inherited(child)
|
28
45
|
child.cached_resource = cached_resource if defined?(@cached_resource)
|
29
46
|
super
|
30
47
|
end
|
31
48
|
end
|
49
|
+
# :nodoc:
|
32
50
|
end
|
33
51
|
end
|
@@ -6,7 +6,16 @@ require "active_support/inflector"
|
|
6
6
|
module ActiveResource # :nodoc:
|
7
7
|
class Collection # :nodoc:
|
8
8
|
include Enumerable
|
9
|
-
delegate :
|
9
|
+
delegate :==, :[], :&, :*, :+, :-, :<=>, :all?, :any?, :as_json, :at, :assoc, :blank?, :bsearch, :bsearch_index,
|
10
|
+
:collect, :combination, :compact, :count, :cycle, :deconstruct, :deep_dup, :dig, :difference, :drop,
|
11
|
+
:drop_while, :each, :each_index, :empty?, :eql?, :excluding, :filter, :fifth, :find_index, :first,
|
12
|
+
:flatten, :forty_two, :fourth, :from, :hash, :include?, :including, :index, :inspect, :intersect?,
|
13
|
+
:intersection, :join, :last, :length, :map, :max, :min, :minmax, :none?, :one?, :pack, :permutation,
|
14
|
+
:pretty_print_cycle, :present?, :product, :reject, :repeated_combination, :repeated_permutation,
|
15
|
+
:rassoc, :reverse, :reverse_each, :rindex, :rotate, :sample, :second, :second_to_last, :select,
|
16
|
+
:shelljoin, :shuffle, :size, :slice, :sort, :sum, :take, :take_while, :third, :third_to_last, :to,
|
17
|
+
:to_a, :to_ary, :to_fs, :to_formatted_s, :to_h, :to_param, :to_query, :to_s, :to_sentence, :to_xml,
|
18
|
+
:transpose, :union, :uniq, :values_at, :without, :zip, to: :request_resources!
|
10
19
|
|
11
20
|
attr_accessor :resource_class, :query_params, :path_params
|
12
21
|
attr_writer :prefix_options
|
@@ -175,6 +184,10 @@ module ActiveResource # :nodoc:
|
|
175
184
|
resource_class.where(new_clauses)
|
176
185
|
end
|
177
186
|
|
187
|
+
def each(&block)
|
188
|
+
request_resources!.each(&block)
|
189
|
+
end
|
190
|
+
|
178
191
|
private
|
179
192
|
def query_string(options)
|
180
193
|
"?#{options.to_query}" unless options.nil? || options.empty?
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative "../active_resource"
|
4
4
|
require "rails"
|
5
5
|
|
6
6
|
module ActiveResource
|
@@ -17,7 +17,7 @@ module ActiveResource
|
|
17
17
|
|
18
18
|
initializer "active_resource.add_active_job_serializer" do |app|
|
19
19
|
if app.config.try(:active_job).try(:custom_serializers)
|
20
|
-
|
20
|
+
require_relative "../active_resource/active_job_serializer"
|
21
21
|
app.config.active_job.custom_serializers << ActiveResource::ActiveJobSerializer
|
22
22
|
end
|
23
23
|
end
|