Module: Sandboxy::Sandboxed::SandboxyClassMethods
- Defined in:
- lib/sandboxy/sandboxed.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/sandboxy/sandboxed.rb', line 25
def method_missing(method, *args)
if method.to_s[/(.+)_environment/]
environment($1)
elsif method.to_s[/(.+)_environment_scoped/]
environment_scoped($1)
else
super
end
end
|
Instance Method Details
#environment(value) ⇒ Object
41
42
43
|
# File 'lib/sandboxy/sandboxed.rb', line 41
def environment(value)
unscope(:joins, :where).environment_scoped value
end
|
#environment_scoped(value) ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'lib/sandboxy/sandboxed.rb', line 45
def environment_scoped(value)
case value
when Sandboxy.configuration.default
left_outer_joins(:sandbox).where(sandboxy: { environment: nil })
else
left_outer_joins(:sandbox).where(sandboxy: { environment: value })
end
end
|
#respond_to_missing?(method, include_private = false) ⇒ Boolean
35
36
37
38
39
|
# File 'lib/sandboxy/sandboxed.rb', line 35
def respond_to_missing?(method, include_private = false)
super ||
method.to_s[/(.+)_environment/] ||
method.to_s[/(.+)_environment_scoped/]
end
|