Class: Reflexive::Methods

Inherits:
Object
  • Object
show all
Defined in:
lib/reflexive/methods.rb

Constant Summary collapse

VISIBILITIES =
[ :public, :protected, :private ].freeze

Instance Method Summary collapse

Constructor Details

#initialize(klass_or_module, options = {}) ⇒ Methods

Returns a new instance of Methods.



6
7
8
9
10
11
# File 'lib/reflexive/methods.rb', line 6

def initialize(klass_or_module, options = {})
  @klass_or_module = klass_or_module
  @ancestor_name_formatter = options.fetch(:ancestor_name_formatter,
                                           default_ancestor_name_formatter)
  @exclude_trite = options.fetch(:exclude_trite, true)
end

Instance Method Details

#allObject



13
14
15
# File 'lib/reflexive/methods.rb', line 13

def all
  @all ||= find_all
end

#constantsObject



21
22
23
24
25
26
27
# File 'lib/reflexive/methods.rb', line 21

def constants
  @constants ||= @klass_or_module.constants(true).map do |c|
    @klass_or_module.const_get(c) rescue nil
  end.compact.select do |c|
    c.instance_of?(Class) || c.instance_of?(Module)
  end # rescue r(@klass_or_module.constants)
end

#descendantsObject



29
30
31
# File 'lib/reflexive/methods.rb', line 29

def descendants
  @descendants ||= Reflexive.descendants(@klass_or_module)
end

#filesObject



17
18
19
# File 'lib/reflexive/methods.rb', line 17

def files
  @files ||= find_all_files
end