Class: Rubyzen::Collections::MethodsCollection

Inherits:
BaseCollection show all
Includes:
Providers::CollectionFilterProvider
Defined in:
lib/rubyzen/collections/methods_collection.rb

Overview

Collection of method declarations with access to parameters, call sites, if statements, rescues, and raises within each method.

Examples:

Ensuring no method has more than 5 parameters

controllers.all_methods.each { |m| expect(m.parameters.size).to be <= 5 }

Instance Method Summary collapse

Methods included from Providers::CollectionFilterProvider

#with_name, #with_name_ending_with, #with_name_including, #with_name_starting_with, #without_name, #without_name_ending_with, #without_name_including, #without_name_starting_with

Methods inherited from BaseCollection

#filter

Instance Method Details

#call_sitesCallSiteCollection

Returns all call sites across every method.

Returns:



36
37
38
39
40
41
42
# File 'lib/rubyzen/collections/methods_collection.rb', line 36

def call_sites
  CallSiteCollection.new(
    flat_map do |method|
      method.call_sites
    end
  )
end

#if_statementsDeclarationCollection

Returns all if-statement declarations across every method.



25
26
27
28
29
30
31
# File 'lib/rubyzen/collections/methods_collection.rb', line 25

def if_statements
  DeclarationCollection.new(
    flat_map do |method|
      method.if_statements
    end
  )
end

#parametersParametersCollection

Returns all parameters across every method.



14
15
16
17
18
19
20
# File 'lib/rubyzen/collections/methods_collection.rb', line 14

def parameters
  ParametersCollection.new(
    flat_map do |method|
      method.parameters
    end
  )
end

#raisesRaisesCollection

Returns all raise declarations across every method.

Returns:



58
59
60
61
62
63
64
# File 'lib/rubyzen/collections/methods_collection.rb', line 58

def raises
  RaisesCollection.new(
    flat_map do |method|
      method.raises
    end
  )
end

#rescuesRescuesCollection

Returns all rescue declarations across every method.

Returns:



47
48
49
50
51
52
53
# File 'lib/rubyzen/collections/methods_collection.rb', line 47

def rescues
  RescuesCollection.new(
    flat_map do |method|
      method.rescues
    end
  )
end