flex-scopes 1.0.5 → 1.0.6

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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/flex/scope.rb +10 -3
  3. data/lib/flex/scopes.rb +1 -1
  4. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.5
1
+ 1.0.6
data/lib/flex/scope.rb CHANGED
@@ -15,14 +15,16 @@ module Flex
15
15
  end
16
16
 
17
17
  def respond_to?(meth, private=false)
18
- super || is_template?(meth) || is_scope?(meth)
18
+ super || is_template?(meth) || is_context_scope?(meth) || is_self_scope?(meth)
19
19
  end
20
20
 
21
21
  def method_missing(meth, *args, &block)
22
22
  super unless respond_to?(meth)
23
23
  case
24
- when is_scope?(meth)
24
+ when is_context_scope?(meth)
25
25
  deep_merge self[:context].send(meth, *args, &block)
26
+ when is_self_scope?(meth)
27
+ deep_merge self[:self_context].send(meth, *args, &block)
26
28
  when is_template?(meth)
27
29
  self[:context].send(meth, deep_merge(*args), &block)
28
30
  end
@@ -34,9 +36,14 @@ module Flex
34
36
  self[:context].respond_to?(:template_methods) && self[:context].template_methods.include?(name.to_sym)
35
37
  end
36
38
 
37
- def is_scope?(name)
39
+ def is_context_scope?(name)
38
40
  self[:context].respond_to?(:scope_methods) && self[:context].scope_methods.include?(name.to_sym)
39
41
  end
40
42
 
43
+ # only used for AR scopes, when you namespace the scope module
44
+ def is_self_scope?(name)
45
+ self[:self_context].respond_to?(:scope_methods) && self[:self_context].scope_methods.include?(name.to_sym)
46
+ end
47
+
41
48
  end
42
49
  end
data/lib/flex/scopes.rb CHANGED
@@ -41,7 +41,7 @@ module Flex
41
41
 
42
42
  # You can start with a non restricted Flex::Scope object
43
43
  def scoped
44
- @scoped ||= Scope[:context => flex.context]
44
+ @scoped ||= Scope[:context => flex.context, :self_context => self]
45
45
  end
46
46
 
47
47
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flex-scopes
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-13 00:00:00.000000000 Z
12
+ date: 2013-11-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: flex
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.0.5
21
+ version: 1.0.6
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 1.0.5
29
+ version: 1.0.6
30
30
  description: Provides an easy to use ruby API to search elasticsearch with ActiveRecord-like
31
31
  chainable and mergeables scopes.
32
32
  email: dd.nexus@gmail.com