like_query 0.1.4 → 0.1.5

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: 4cbeab01984ef5c872a39167c49487b4ad47ed80db8c44f5bac94b2db3dc0c7d
4
- data.tar.gz: 49bd373e430ca83c3b533913b5adf83aa2191bc8fbaab6ad1c19c85cd014d577
3
+ metadata.gz: dcd1bdff2f0937db63147911ec7703739405d67bc30f35c19aa8261ee1ea5c38
4
+ data.tar.gz: e3fd7d9a4a235ed6010f3a950827d69c87e1d351908b915ae29b453c3d91bf90
5
5
  SHA512:
6
- metadata.gz: e3ca7b08324a456eb2440d765d359c154378db6fb833d377be1236f7021f7acb0420a879af59d6558bd511888c50126edb80c8618b731ad6d1c2f429a6b47a04
7
- data.tar.gz: da945a9c6f70920557841285aa792274c32f22f1aa79884ce041d21789e3b5d2882f1af3be6583335c6ca627f576b53a5ad7bb7086ed8ca36b012c6acee42175
6
+ metadata.gz: c73483e9cbd7cf1d93da216d7210780694fd27445241e860e93fbafe0973cefdc2c35eaa01319ab1a8f5c017cf1952e37764bf8606fd3b4e4633f21634118b7c
7
+ data.tar.gz: ea335097891ce39c54d1177aad72d5b311b944c8923b37c3718c23e09948caeb98f980a47816be4e6b65258667e0b81bc6367c2a5e2781faf8f1e10f8fdfbb3b
@@ -101,23 +101,25 @@ module LikeQuery
101
101
  match_number = str.match(/^(\d+(?:\.\d+)?)$/)
102
102
  match_range = str.match(/^(\d+(?:\.\d+)?)(\.\.)(\d+(?:\.\d+)?)$/)
103
103
 
104
- if match_range
105
- mr = match_range.to_s
106
- {
107
- float_from: mr.split('..').first.to_f,
108
- float_until: mr.split('..').last.to_f,
109
- }
110
- elsif match_number
111
- mn = match_number.to_s
112
- {
113
- float_from: mn,
114
- float_until: mn,
115
- }
116
- else
117
- {
118
- string: "%#{str}%"
119
- }
120
- end
104
+ res = if match_range
105
+ mr = match_range.to_s
106
+ {
107
+ float_from: mr.split('..').first.to_f,
108
+ float_until: mr.split('..').last.to_f,
109
+ }
110
+ elsif match_number
111
+ mn = match_number.to_s
112
+ {
113
+ float_from: mn,
114
+ float_until: mn,
115
+ }
116
+ else
117
+ {
118
+ string: "%#{str}%"
119
+ }
120
+ end
121
+ res[:string] = "%#{str}%"
122
+ res
121
123
  end
122
124
 
123
125
  def create_arel(schema_column, search_string, association = nil)
@@ -130,10 +132,10 @@ module LikeQuery
130
132
  end
131
133
  arel = base_object.arel_table[schema_column]
132
134
 
133
- if search_string[:float_from]
134
- if [:float, :decimal, :big_decimal, :integer, :bigint].include?(type)
135
- arel.between(search_string[:float_from]..search_string[:float_until])
136
- end
135
+ if search_string[:float_from] && [:float, :decimal, :big_decimal, :integer, :bigint].include?(type)
136
+
137
+ arel.between(search_string[:float_from]..search_string[:float_until])
138
+
137
139
  else
138
140
  arel.matches(search_string[:string])
139
141
  end
@@ -1,3 +1,3 @@
1
1
  module LikeQuery
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: like_query
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - christian