recourse 1.0.0 → 1.0.2

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: cd168efcdd88afa58c1b4bc5a5c7c4fc71bc91caec7b7a8ad344f41d7f2b3eb0
4
- data.tar.gz: 4c6858fa894182eda4378571397b962fff778d172f7e749cc31e976776c71f50
3
+ metadata.gz: 238c0c227f1cd34c3aa991972792acbcdaf26ec64149f833e072fb106cae16e7
4
+ data.tar.gz: 70769ca47575f9320d2a7acdbe1ec0edcb7db009afcaad594ca60319dfccc1ca
5
5
  SHA512:
6
- metadata.gz: 065fcb2ed2b597570045209d931b5dc74f6e12b30f39e3456dbbb7a635038a62d8b4e542764297df205b51c1163fe86937613ac5c6d69cd1def9f2dfeb40262d
7
- data.tar.gz: ca93b998e63631993f14b55dc1ed8f2dcd3d9380eb57198f11e235cbaa366520a2f1247a4745e0c5c7b1cdcd9f1daf298b448ef975e29ac255d02ccca6e0340c
6
+ metadata.gz: 33d0deb2d2f1300d0cbdf0fa90337564a4325d5bd2a22a28ba8a2683de167f1847d8f2e32650e47943ebdd2ec385947a78abb2ceb25450d206c6eb0f10667514
7
+ data.tar.gz: 84fb9a4fc6e3daf58b28c99f106a8520ce17a18cc76ae3daeedc14b61f9533806dbc2a82b0f9beb7250826f5d9406a28f00ff7cfbc9549ee77b468e0583c3e78
data/README.md CHANGED
@@ -27,7 +27,6 @@ In a resourceful Active Record model:
27
27
  - `recourse_includes`: the associations to include when fetching the resources
28
28
  - `recourse_order`: the SQL to sort the resources by
29
29
  - `recourse_positionable?`: whether the model has a position field to drag'n'drop sort
30
- - `recourse_searchable?`: whether the model has Ransack enabled for searches
31
30
 
32
31
  Anywhere:
33
32
 
@@ -12,7 +12,7 @@ class RecourseController < ApplicationController
12
12
  private
13
13
 
14
14
  def paginate(model, includes: [], order: nil)
15
- if model.recourse_searchable?
15
+ if model.recourse_searchable? || model.recourse_sortable?
16
16
  @q = model.ransack params[:q]
17
17
  @q.sorts = (order || 'created_at desc') if @q.sorts.empty?
18
18
  pagy includes.present? ? @q.result.includes(includes) : @q.result.distinct(true)
@@ -28,9 +28,14 @@ module Recourse
28
28
  false
29
29
  end
30
30
 
31
- # @return [Boolean] whether Ransack attributes are defined on the resource.
31
+ # @return [Boolean] whether Ransack search attributes are defined on the resource.
32
32
  def recourse_searchable?
33
- ransackable_attributes.any? || ransortable_attributes.any?
33
+ ransackable_attributes.any?
34
+ end
35
+
36
+ # @return [Boolean] whether Ransack sort attributes are defined on the resource.
37
+ def recourse_sortable?
38
+ ransortable_attributes.any?
34
39
  end
35
40
  end
36
41
  end
@@ -1,6 +1,8 @@
1
1
  require 'recourse/model/recoursive'
2
2
  require 'recourse/model/searchable'
3
3
 
4
- # TODO: Replace these with on_load
5
- ActiveRecord::Base.extend Recourse::Recoursive
6
- ActiveRecord::Base.extend Recourse::Searchable
4
+
5
+ ActiveSupport.on_load(:active_record) do
6
+ extend Recourse::Recoursive
7
+ extend Recourse::Searchable
8
+ end
@@ -1,3 +1,3 @@
1
1
  module Recourse
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recourse
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo