J
Joshua Muheim
Hi all
I'm developing an authorization plugin that looks like the following so
far:
module Incense
module Authorization
def self.included(base_class)
base_class.extend(ClassMethods)
end
module ClassMethods
def performs_authorization(options = {})
before_filter repare_user
include(InstanceMethods)
end
end
end
module InstanceMethods
private
def prepare_user
session[:user] ||= Member.find_by_id(2) # When there's no user_id
in the session, then use #2 for Guest
...
end
Because I extracted this functionality from an application, in
prepare_user() there's still a hardwired "Member" model used. But in
another application I need this to be a "User" model, so I'd like to be
able to specify the model to use in the options hash of the
performs_authorization() method. So how can I achieve this? Do I have to
use define_method() in the context of performs_authorization? This would
work, I guess, but I don't like it very much... Isn't there another way?
Thanks
Josh
I'm developing an authorization plugin that looks like the following so
far:
module Incense
module Authorization
def self.included(base_class)
base_class.extend(ClassMethods)
end
module ClassMethods
def performs_authorization(options = {})
before_filter repare_user
include(InstanceMethods)
end
end
end
module InstanceMethods
private
def prepare_user
session[:user] ||= Member.find_by_id(2) # When there's no user_id
in the session, then use #2 for Guest
...
end
Because I extracted this functionality from an application, in
prepare_user() there's still a hardwired "Member" model used. But in
another application I need this to be a "User" model, so I'd like to be
able to specify the model to use in the options hash of the
performs_authorization() method. So how can I achieve this? Do I have to
use define_method() in the context of performs_authorization? This would
work, I guess, but I don't like it very much... Isn't there another way?
Thanks
Josh