scopie 1.0.6 → 1.1.0

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: 39d4358a795eed7bb94f8b10f07fce8aac27e9d6
4
- data.tar.gz: a016a71aa93ed9407397599b2a707fe83df9346f
3
+ metadata.gz: 8bee02f08df53a4ada09a728fbba17acddc3edab
4
+ data.tar.gz: d57901f26a3758979ac6da8b0e2d16c6752df7c3
5
5
  SHA512:
6
- metadata.gz: 33709ce61f55381b29028f45181d870c6dd27cf9c757fb74986b772f642fa9af16e64d9b346565a741529191ac25f7dc6b0ac9abd67e04d3516cda0298ac048e
7
- data.tar.gz: 24656a8c4825c1a0cf7e11e82e242348fea8e3aad961bb54f686e68d75e906b223f5068a4d35cba27b38ce3d977dde650ac2aa86f422b2b0334f6194a902033b
6
+ metadata.gz: 4420ad199466801d4af7f85b639c448d97231b2e0d86b4c445930a30a8a2ee8ed2a6c9efc56019cfe36778a33b233aa7f3c04dfdd40f0a0c702605b1a07f2018
7
+ data.tar.gz: 19cbd4bb3c08a6e9ea0723424658870ba8060838bb239c2de9f0dd217c0cdd370ace7c2958e56944b3e10637893495213a6ece618b7fb62d936ff75c48e713a7
data/README.md CHANGED
@@ -147,6 +147,6 @@ Scopie supports several options:
147
147
 
148
148
  ## Thanks
149
149
 
150
- Scopie was inspired by [has_scope](http://github.com/plataformatec/has_scope) and [pundit](http://github.com/elabs/pubdit).
150
+ Scopie was inspired by [has_scope](http://github.com/plataformatec/has_scope) and [pundit](http://github.com/elabs/pundit).
151
151
 
152
152
  Thanks to both.
@@ -69,7 +69,7 @@ class Scopie::Base
69
69
  value = scope_value(scope_name, options, hash)
70
70
  next unless scope_applicable?(value, options, method)
71
71
 
72
- [scope_name, value.coerced]
72
+ [scope_name, value]
73
73
  end
74
74
 
75
75
  scopes.compact!
@@ -80,9 +80,11 @@ class Scopie::Base
80
80
 
81
81
  def apply_scope(scope_name, target, value, hash)
82
82
  result = if respond_to?(scope_name)
83
- public_send(scope_name, target, value, hash)
83
+ public_send(scope_name, target, value.coerced, hash)
84
84
  else
85
- target.public_send(scope_name, value)
85
+ args = [scope_name]
86
+ args << value.coerced if value.present? || value.allow_blank?
87
+ target.public_send(*args)
86
88
  end
87
89
 
88
90
  if Scopie::RESULTS_TO_IGNORE.include?(result)
@@ -109,7 +111,7 @@ class Scopie::Base
109
111
  return false unless method_applicable?(method, options)
110
112
  return false unless value.given?
111
113
 
112
- value.present? || !!options[:allow_blank]
114
+ true
113
115
  end
114
116
 
115
117
  def reduced_hash(hash, options)
@@ -27,6 +27,10 @@ class Scopie::Value
27
27
  value.respond_to?(:empty?) ? !value.empty? : !!value
28
28
  end
29
29
 
30
+ def allow_blank?
31
+ @options[:allow_blank]
32
+ end
33
+
30
34
  private
31
35
 
32
36
  def fetch_type
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Scopie
4
- VERSION = '1.0.6'.freeze
4
+ VERSION = '1.1.0'.freeze
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scopie
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yury Kotov