simple_form_ransack 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6388e386226444a9d11053a23965ee65194bea1
4
- data.tar.gz: a9f5076f06493fc42e70680d9537e04496d454e2
3
+ metadata.gz: d7503aa043a1137a17d483feb14508f2e3ed272b
4
+ data.tar.gz: f4d9499bac8ea5bfb29bf7bce45c0069344f4c01
5
5
  SHA512:
6
- metadata.gz: d93fd88ced3b4bf0e342c10a7cbf33eb2a0361c1b898e88b82585c0a8b12459671c10d47d59ee9a3b50ae75e8b0270c6aefda9d5a4ccfa460a15ee0075056e8d
7
- data.tar.gz: 4f57f1f6463110a957d2059e88ece7de474caf1b0e9372552f60ea4ef154e2e66a4a8a003206eaff07528358b5423cb1814b4e0e122e416b891f28e060d381f3
6
+ metadata.gz: bc144ad51d2757b536d930c71c31ee80fc3122e31ee89d4d9d64c1dea73857158931d1388226678691f78496cdc98138bc2e68febd468a7b29969e6569349674
7
+ data.tar.gz: 400993d49561a440c86d426293282d40493a30d3c60f5d226c22ff379ff06c5e6aee8fff1345201459e34df4f1bf159b7df2a5db1e34599d53648fb3fe791f81
@@ -1,11 +1,16 @@
1
1
  class SimpleFormRansack::FormProxy
2
2
  def self.predicates_regex
3
3
  unless @predicates_regex
4
- predicates = Ransack::Configuration
5
- .predicates
6
- .map(&:first)
7
- .map { |predicate| Regexp.escape(predicate) }
8
- .join("|")
4
+ if Object.const_defined?(:Ransack)
5
+ predicates = Ransack::Configuration
6
+ .predicates
7
+ .map(&:first)
8
+ .map { |predicate| Regexp.escape(predicate) }
9
+ .join("|")
10
+ else
11
+ # BazaModels support
12
+ predicates = "cont|eq|gteq|lteq|gt|lt|eq_any"
13
+ end
9
14
 
10
15
  @predicates_regex = /^(.+)_(#{predicates})$/
11
16
  end
@@ -15,7 +20,6 @@ class SimpleFormRansack::FormProxy
15
20
 
16
21
  def initialize(args)
17
22
  @ransack = args.fetch(:ransack)
18
- @object = @ransack.object
19
23
  @class = @ransack.klass
20
24
  @params = args.fetch(:params)
21
25
  @form = args.fetch(:form)
@@ -1,11 +1,18 @@
1
- require "ransack"
1
+ begin
2
+ require "ransack"
3
+ ransack_loaded = true
4
+ rescue LoadError
5
+ ransack_loaded = false
6
+ end
2
7
 
3
- # This saves the params given to Ransack, so they can be recalled later
4
- class Ransack::Search
5
- alias old_build build
8
+ if ransack_loaded
9
+ # This saves the params given to Ransack, so they can be recalled later
10
+ class Ransack::Search
11
+ alias old_build build
6
12
 
7
- def build(params = {})
8
- @_registered_params = params
9
- old_build(params)
13
+ def build(params = {})
14
+ @_registered_params = params
15
+ old_build(params)
16
+ end
10
17
  end
11
18
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleFormRansack
2
- VERSION = "0.0.15".freeze
2
+ VERSION = "0.0.16".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_form_ransack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Johansen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-30 00:00:00.000000000 Z
11
+ date: 2016-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -217,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
217
  version: '0'
218
218
  requirements: []
219
219
  rubyforge_project:
220
- rubygems_version: 2.4.0
220
+ rubygems_version: 2.2.2
221
221
  signing_key:
222
222
  specification_version: 4
223
223
  summary: Ransack and SimpleForm combined.