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

Version Path
infopark_fiona_connector-7.0.1.6.1.6.rc4 lib/rails_connector/authenticable.rb
infopark_fiona_connector-7.0.1.6.1.6.rc3 lib/rails_connector/authenticable.rb
infopark_fiona_connector-7.0.1.6.1.6.rc2 lib/rails_connector/authenticable.rb
infopark_fiona_connector-7.0.1.6.1.6.rc1 lib/rails_connector/authenticable.rb
infopark_fiona_connector-7.0.1.5.2.7.rc1 lib/rails_connector/authenticable.rb
infopark_fiona_connector-7.0.1.5.2.4.rc2 lib/rails_connector/authenticable.rb
infopark_fiona_connector-7.0.1.5.2.4.rc1 lib/rails_connector/authenticable.rb
infopark_fiona_connector-7.0.1.5.2.3.rc8 lib/rails_connector/authenticable.rb
infopark_fiona_connector-7.0.1.5.2.3.rc7 lib/rails_connector/authenticable.rb
infopark_fiona_connector-7.0.1.5.2.3.rc6 lib/rails_connector/authenticable.rb
infopark_fiona_connector-7.0.1.5.2.3.rc5 lib/rails_connector/authenticable.rb