Sha256: f80d942c409d46fa72a81a73d03f1887d3354036d2002178614eced11df127fd

Contents?: true

Size: 825 Bytes

Versions: 12

Compression:

Stored size: 825 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

    private

    def self.instance_method_defined?(mod, method_name)
      mod.instance_methods.include?(method_name) or
        mod.protected_instance_methods.include?(method_name) or
        mod.private_instance_methods.include?(method_name)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
infopark_rails_connector-6.8.0.539.93842523 lib/rails_connector/authenticable.rb
infopark_rails_connector-6.8.0.529.114081979 lib/rails_connector/authenticable.rb
infopark_rails_connector-6.8.0.518.30999728 lib/rails_connector/authenticable.rb
infopark_rails_connector-6.8.0.515.34928522 lib/rails_connector/authenticable.rb
infopark_rails_connector-6.8.0.498.46559598 lib/rails_connector/authenticable.rb
infopark_rails_connector-6.8.0.480.261594408 lib/rails_connector/authenticable.rb
infopark_rails_connector-6.8.0.444.171626367 lib/rails_connector/authenticable.rb
infopark_rails_connector-6.8.0.406.131718077 lib/rails_connector/authenticable.rb
infopark_rails_connector-6.8.0.356.19698103 lib/rails_connector/authenticable.rb
infopark_rails_connector-6.8.0.348.160665197 lib/rails_connector/authenticable.rb
infopark_rails_connector-6.8.0.328.4a753fc lib/rails_connector/authenticable.rb
infopark_rails_connector-6.8.0.322.c003f11 lib/rails_connector/authenticable.rb