lib/emerson/scope.rb in emerson-0.1.0.pre.1 vs lib/emerson/scope.rb in emerson-0.1.0.pre.2
- old
+ new
@@ -1,8 +1,9 @@
require 'action_controller/base'
module Emerson
+ # Add helpers for request-base, scoped resource loading.
module Scope
def self.included(base)
base.class_eval do
extend ClassMethods
# TODO: consider...
@@ -51,15 +52,11 @@
end
end
end
def current_scope
- @_current_scope ||= begin
- if @scope.present?
- @scope.class.model_name.plural.intern
- end
- end
+ scoped && @scope
end
protected
def scope_from_params
@@ -73,11 +70,9 @@
private
def class_for(type)
type.to_s.classify.constantize
- rescue
- nil
end
def default_scope
klass = class_for(singular(self.class.name.sub(/Controller$/, '')))
klass.scoped