module RailsConnector module Authenticable def self.included(mod) %w(logged_in? admin? current_user).each do |method_name| unless instance_method_defined?(mod, method_name) mod.class_eval do private define_method(method_name, InstanceMethods.method(method_name).to_proc) end end mod.send(:helper_method, method_name) end end module InstanceMethods def self.logged_in?; false; end def self.admin?; false; end def self.current_user; nil; end end private def self.instance_method_defined?(mod, method_name) ( mod.instance_methods + mod.protected_instance_methods + mod.private_instance_methods ).map(&:to_s).include?(method_name) end end end