Sha256: f156180d9118bfc41260ce5d1be5fb5e4f39f06972e6e2fb42b23cbea7cb86fd
Contents?: true
Size: 819 Bytes
Versions: 11
Compression:
Stored size: 819 Bytes
Contents
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 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
Version data entries
11 entries across 11 versions & 1 rubygems