class SystemNavigation::MethodHash

Public Class Methods

create(**args) click to toggle source
# File lib/system_navigation/method_hash.rb, line 3
def self.create(**args)
  self.new(args)
end
new(based_on: nil, include_super: nil) click to toggle source
Calls superclass method
# File lib/system_navigation/method_hash.rb, line 8
def initialize(based_on: nil, include_super: nil)
  @hash = super()

  if based_on
    @hash.merge!({
      public: {
        instance: based_on.public_instance_methods(include_super),
        singleton: based_on.singleton_class.public_instance_methods(include_super)
      },
      private: {
        instance: based_on.private_instance_methods(include_super),
        singleton: based_on.singleton_class.private_instance_methods(include_super)
      },
      protected: {
        instance: based_on.protected_instance_methods(include_super),
        singleton: based_on.singleton_class.protected_instance_methods(include_super)
      }
    })
  else
    @hash.merge!(empty_hash)
  end
end

Public Instance Methods

as_array() click to toggle source
# File lib/system_navigation/method_hash.rb, line 31
def as_array
  self.values.map { |h| h[:instance] + h[:singleton] }.flatten.compact
end
empty?() click to toggle source
# File lib/system_navigation/method_hash.rb, line 35
def empty?
  self == empty_hash
end

Protected Instance Methods

empty_hash() click to toggle source
# File lib/system_navigation/method_hash.rb, line 41
def empty_hash
  {
    public: {instance: [], singleton: []},
    private: {instance: [], singleton: []},
    protected: {instance: [], singleton: []}
  }
end