plain_query 0.1.0 → 0.1.1

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: bd8f5297c612866609495705363e33a5b04d43acfc4169b6db99ac7fd831a58c
4
- data.tar.gz: 7a8adf2c33adbd013d68e1989970385834861e6c3d474d88785f94bb473501c9
3
+ metadata.gz: dee05c4d00595dfab9fd6e7d5a2f154a5859a4be75ef3f73e38260b2e06ea300
4
+ data.tar.gz: d0e1115a8da4c3f78cb97fe3107743ca1f4aab9874260f9a26ea86e68da64594
5
5
  SHA512:
6
- metadata.gz: 95163e316ad68b4c3dd0141030ccc5e58c6de3514aca0658bcb556d4494d42cdd6260a62f4e8e58206e3a804ed3f7ac26eb976c3272c8b5ad700cecf7ea16399
7
- data.tar.gz: 31f79976ab181c103bd62823c0be4e4978da81925beb9a885515970cd0301a5a1f86dd280b079d7660af771c0d4c33032d8924edf1ec68b987b91787ed444c78
6
+ metadata.gz: 676f7357d5ece333078b7434451ee1d26f4512a2e7e9ede0ddba7530fad1a32da8568679f6835da4b1058d86ff5bf4914e9c1c04d6846da291f36466e49e7b3a
7
+ data.tar.gz: bbb09631bb05e2ed2cbbc52346ea18fc42813a50c1f790b786a9da5d9cf6b302b5ee1b70c2335739176640e0668957dce4334be6dabffac9c495ff8f871bba1f
data/README.md CHANGED
@@ -40,7 +40,7 @@ Query steps perform in writing order.
40
40
  class UsersQuery < PlainQuery
41
41
  model User
42
42
 
43
- query_step :filter_by_activity, if: { options[:only_active] }
43
+ query_step :filter_by_activity, if: -> { options[:only_active] }
44
44
  query_step :filter_by_phone_presence
45
45
  query_step :order_by_name
46
46
 
@@ -137,8 +137,6 @@ end
137
137
 
138
138
  ## Contributing
139
139
 
140
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/plain_query. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
141
-
142
140
  1. Fork it
143
141
  2. Create your feature branch (git checkout -b my-new-feature)
144
142
  3. Commit your changes (git commit -am 'Add some feature')
@@ -1,6 +1,7 @@
1
1
  # Realises methods for scope building by execution of sequence of steps
2
2
  # Query class defines query steps:
3
3
  # query_step :filter_by_status, if: -> { options[:status].present? }
4
+ #
4
5
  # def filter_by_status
5
6
  # relation.where(status: options[:status])
6
7
  # end
@@ -12,10 +13,8 @@ class PlainQuery
12
13
  @options = options
13
14
  @steps = self.class.steps
14
15
 
15
- # Validates initial relation format. Allowed only ActiveRecord::Relation, model class.
16
- if relation.nil?
17
- raise(RelationRequired, 'Queries require a base relation defined')
18
- elsif !relation.is_a?(ActiveRecord::Relation)
16
+ # Validates initial relation format. Allowed only ActiveRecord::Relation.
17
+ unless relation.is_a?(ActiveRecord::Relation)
19
18
  raise(RelationRequired, 'Queries accept only ActiveRecord::Relation as input')
20
19
  end
21
20
  end
@@ -34,7 +33,7 @@ class PlainQuery
34
33
 
35
34
  # Executes query mutation and checks that step returns ActiveRecord::Relation
36
35
  mutated_query = send(step_name)
37
- if !mutated_query.is_a?(ActiveRecord::Relation)
36
+ unless mutated_query.is_a?(ActiveRecord::Relation)
38
37
  raise(RelationIsIncorrect, 'Scope must be ActiveRecord::Relation')
39
38
  end
40
39
 
@@ -46,7 +45,7 @@ class PlainQuery
46
45
 
47
46
  # Executes if and unless conditions, conditions must contain object method name or proc (lambda)
48
47
  def exec_condition(condition)
49
- if condition.is_a?(String) || condition.is_a?(Symbol)
48
+ if [String, Symbol].member?(condition.class)
50
49
  !!send(condition)
51
50
  elsif condition.is_a?(Proc)
52
51
  !!instance_exec(&condition)
@@ -1,3 +1,3 @@
1
1
  class PlainQuery
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plain_query
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - gl-pv
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-10 00:00:00.000000000 Z
11
+ date: 2022-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord