2009-10-10 07:37:22 -04:00
|
|
|
module Devise
|
|
|
|
module Controllers
|
|
|
|
module Resources
|
|
|
|
|
2009-10-10 08:32:51 -04:00
|
|
|
# def self.included(base)
|
|
|
|
# base.class_eval do
|
|
|
|
# helper_method :resource, :resource_name, :resource_class
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
|
|
|
|
def resource
|
|
|
|
@resource ||= instance_variable_get(:"@#{resource_name}")
|
|
|
|
end
|
|
|
|
|
|
|
|
def resource=(new_resource)
|
|
|
|
@resource = instance_variable_set(:"@#{resource_name}", new_resource)
|
|
|
|
end
|
|
|
|
|
2009-10-10 07:37:22 -04:00
|
|
|
def resource_name(object=nil)
|
|
|
|
@resource_name ||= Devise.resource_name(resource_name_or_request_path(object))
|
|
|
|
end
|
|
|
|
|
|
|
|
def resource_class
|
|
|
|
@resource_class ||= Devise.resource_class(resource_name_or_request_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def resource_name_or_request_path(object=nil)
|
|
|
|
object ? object.class.name : request.path.split('/').second
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|