scoping 0.0.1 → 0.0.2

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: bf670267565ddc463c9db198a7ada3844bedfc44
4
- data.tar.gz: 018e1965ce44d3bf3cf72495e49cb72450613f67
3
+ metadata.gz: 8a12f75d29a3d3175dabf4cd22e60a501b8fcdeb
4
+ data.tar.gz: 870c0de94b116be0d1cbc882b5b6b12ea5ac55ef
5
5
  SHA512:
6
- metadata.gz: e5ff5856a942ef716e168af4a2807d4c8fe18e7ab22696184cc5412236e2fe2934fd566e00434b75065f35e61848537350da2b2843a71b10dbb59dd04d315348
7
- data.tar.gz: 01f8918f0c44d6f1c4b6f4567fac64fefd36fb06700c17d69c090609f178b000c33a6eb3697400b049fcec8bbaf9ca227e922259353bb420627444527171c010
6
+ metadata.gz: 2d27e42762598157e5002d62248eac4a4bbba55b0574cc58da305da65333ff10f17fc3cf438049e5ef8bcf62a13d0d17c2a6d18512458ff09c40710ada0fa4df
7
+ data.tar.gz: 82f55e9a93ce200809f5abaad89c6e877ee362abe0a9fd71d84beab1c07c889d80b4714c097b85af5dd444006ce99f38262ed0c4bd23e0d79fc2081bbdc04e5f
@@ -111,7 +111,7 @@ module Scoping
111
111
  # @param [String] field
112
112
  # @param [Object] value
113
113
  def apply_field_on_current_scope(field, value)
114
- arity = @base_scope.method(field).arity
114
+ arity = arity_for(field)
115
115
  if arity == 0
116
116
  if value == "1" || value == true
117
117
  @current_scope = @current_scope.public_send field
@@ -121,6 +121,17 @@ module Scoping
121
121
  end
122
122
  end
123
123
 
124
+ # Returns arity for given scope.
125
+ #
126
+ # @return [Fixnum]
127
+ def arity_for(scope)
128
+ if @base_scope.respond_to?(:klass)
129
+ @base_scope.klass
130
+ else
131
+ @base_scope
132
+ end.method(field).arity
133
+ end
134
+
124
135
  # Return the filter fields.
125
136
  #
126
137
  # @return [Array]
@@ -1,3 +1,3 @@
1
1
  module Scoping
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: scoping
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jiří Zajpt