Class: MerbResourceScope::Controller::ScopedResourceMixin::ResourceScope
- Inherits:
-
Object
- Object
- MerbResourceScope::Controller::ScopedResourceMixin::ResourceScope
show all
- Defined in:
- lib/merb-resource-scope/controller/scoped_resource_mixin.rb
Overview
Proxy class to provide a consistent API for resource_scope. passing all method calls to the current_scope
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ResourceScope.
47
48
49
|
# File 'lib/merb-resource-scope/controller/scoped_resource_mixin.rb', line 47
def initialize(controller)
@controller = controller
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
67
68
69
70
71
72
73
|
# File 'lib/merb-resource-scope/controller/scoped_resource_mixin.rb', line 67
def method_missing(method, *args, &block)
if current_scope.respond_to?(method)
current_scope.send(method, *args, &block)
else
super
end
end
|
Instance Attribute Details
#controller ⇒ Object
Returns the value of attribute controller.
45
46
47
|
# File 'lib/merb-resource-scope/controller/scoped_resource_mixin.rb', line 45
def controller
@controller
end
|
Instance Method Details
#_current_specification ⇒ Object
55
56
57
|
# File 'lib/merb-resource-scope/controller/scoped_resource_mixin.rb', line 55
def _current_specification
@_current_specification ||= controller._current_specification
end
|
#_enclosing_resource ⇒ Object
51
52
53
|
# File 'lib/merb-resource-scope/controller/scoped_resource_mixin.rb', line 51
def _enclosing_resource
@_enclosing_resource ||= controller.enclosing_resource
end
|
#current_scope ⇒ Object
63
64
65
|
# File 'lib/merb-resource-scope/controller/scoped_resource_mixin.rb', line 63
def current_scope
@current_scope ||= _enclosing_resource ? _enclosing_resource.send(_current_specification.association_method) : _current_specification.klass
end
|
#respond_to?(method) ⇒ Boolean
59
60
61
|
# File 'lib/merb-resource-scope/controller/scoped_resource_mixin.rb', line 59
def respond_to?(method)
super || current_scope.respond_to?(method)
end
|