1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00
heartcombo--devise/lib/devise/controllers/helpers.rb
2009-10-12 08:37:42 -03:00

40 lines
879 B
Ruby

module Devise
module Controllers
module Helpers
def self.included(base)
base.class_eval do
helper_method :resource, :resource_name, :resource_class
end
end
def resource
instance_variable_get(:"@#{resource_name}")
end
def resource_name
devise_mapping.name
end
def resource_class
devise_mapping.to
end
protected
def devise_mapping
@devise_mapping ||= Devise.find_mapping_by_path(request.path)
end
def resource=(new_resource)
instance_variable_set(:"@#{resource_name}", new_resource)
end
def set_flash_message(key, kind)
flash[key] = I18n.t(:"#{resource_name}.#{kind}",
:scope => [:devise, controller_name.to_sym], :default => kind)
end
end
end
end