Class: Rubyzen::Collections::BlocksCollection

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

Overview

Collection of block declarations (do…end / { }) found in files or methods.

Examples:

Finding blocks passed to a specific method

project.files.blocks.with_method_name('describe')

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 found inside every block.

Returns:



21
22
23
24
# File 'lib/rubyzen/collections/blocks_collection.rb', line 21

def call_sites
  all_call_sites = flat_map(&:call_sites)
  CallSiteCollection.new(all_call_sites)
end

#with_method_name(method_name) ⇒ BlocksCollection

Filters blocks by the method name they are passed to.

Parameters:

  • method_name (String)

    the method name to match

Returns:



14
15
16
# File 'lib/rubyzen/collections/blocks_collection.rb', line 14

def with_method_name(method_name)
  filter { |block| block.method_name == method_name }
end