Class: SystemNavigation::MethodHash
- Inherits:
-
Hash
- Object
- Hash
- SystemNavigation::MethodHash
- Defined in:
- lib/system_navigation/method_hash.rb
Overview
Class Method Summary collapse
Instance Method Summary collapse
- #as_array ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(based_on: nil, include_super: nil) ⇒ MethodHash
constructor
A new instance of MethodHash.
Constructor Details
#initialize(based_on: nil, include_super: nil) ⇒ MethodHash
Returns a new instance of MethodHash.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# 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 |
Class Method Details
.create(**args) ⇒ Object
3 4 5 |
# File 'lib/system_navigation/method_hash.rb', line 3 def self.create(**args) self.new(args) end |
Instance Method Details
#as_array ⇒ Object
31 32 33 |
# File 'lib/system_navigation/method_hash.rb', line 31 def as_array self.values.map { |h| h[:instance] + h[:singleton] }.flatten.compact end |
#empty? ⇒ Boolean
35 36 37 |
# File 'lib/system_navigation/method_hash.rb', line 35 def empty? self == empty_hash end |