arel_search 0.0.1 → 0.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.
data/README.md CHANGED
@@ -18,7 +18,24 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ ### Basic
22
+
23
+ params = {'orders.status.eq' => 50}
24
+ ArelSearch::Base.new(Order, params).search
25
+
26
+ ### Query by association
27
+
28
+ params = {'orders.status.eq' => 50, 'customer.name.matches' => 'Marcus'}
29
+ ArelSearch::Base.new(Order, params).search
30
+
31
+ ### Paginate (3rd party)
32
+
33
+ params = {'orders.status.eq' => 50, 'customer.name.matches' => 'Marcus'}
34
+ ArelSearch::Base.new(Order, params).search(page: 1, per_page: 10)
35
+
36
+ ## TODO
37
+
38
+ Work with namespace
22
39
 
23
40
  ## Contributing
24
41
 
@@ -3,18 +3,14 @@
3
3
  # Basic usage:
4
4
  #
5
5
  # params = {'orders.status.eq' => 50}
6
- # ArelSearch::Base.new(Order, params).search_all
6
+ # ArelSearch::Base.new(Order, params).search
7
7
  #
8
8
  #
9
9
  # Query by association
10
10
  # params = {'orders.status.eq' => 50, 'customer.name.matches' => 'Marcus'}
11
11
  #
12
- # Paginate
13
- # ArelSearch::Base.new(Order, params).search(page: 1, per_page: 10)
14
- #
15
- # TODO:
16
- #
17
- # Implement NoMethodError for columns and Arel predications
12
+ # Paginate (3rd party)
13
+ # ArelSearch::Base.new(Order, params).search.paginate(page: 1, per_page: 10)
18
14
  module ArelSearch
19
15
  class Base
20
16
  attr_reader :fields, :model, :params
@@ -26,15 +22,11 @@ module ArelSearch
26
22
  @params = params
27
23
  end
28
24
 
29
- def search_all
25
+ def search
30
26
  scope_conditions
31
27
  self.scope
32
28
  end
33
29
 
34
- def search(page=1, per_page=20)
35
- self.search_all.paginate(per_page: per_page, page: page)
36
- end
37
-
38
30
  private
39
31
 
40
32
  def scope_conditions
@@ -1,3 +1,3 @@
1
1
  module ArelSearch
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arel_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: