Class: Woods::Extractors::ActionCableExtractor
- Inherits:
-
Object
- Object
- Woods::Extractors::ActionCableExtractor
- Includes:
- SharedDependencyScanner, SharedUtilityMethods
- Defined in:
- lib/woods/extractors/action_cable_extractor.rb
Overview
ActionCableExtractor handles ActionCable channel extraction via runtime introspection.
Reads ‘ActionCable::Channel::Base.descendants` to discover channels, then inspects each channel’s stream subscriptions, actions, broadcast patterns, and source code. Each channel becomes one ExtractedUnit with metadata about streams, actions, and broadcast patterns.
Constant Summary collapse
- LIFECYCLE_METHODS =
Lifecycle methods that are not user-defined actions
%i[subscribed unsubscribed].freeze
Constants included from SharedDependencyScanner
SharedDependencyScanner::FORM_ACTION_HELPER, SharedDependencyScanner::ROUTE_HELPER_PATTERN
Instance Method Summary collapse
-
#extract_all ⇒ Array<ExtractedUnit>
Extract all ActionCable channels as ExtractedUnits.
-
#extract_channel(klass) ⇒ ExtractedUnit?
Extract a single channel class into an ExtractedUnit.
-
#initialize ⇒ ActionCableExtractor
constructor
A new instance of ActionCableExtractor.
Methods included from SharedDependencyScanner
#extract_constantize_targets, #scan_common_dependencies, #scan_form_dependencies, #scan_job_dependencies, #scan_mailer_dependencies, #scan_model_dependencies, #scan_navigation_dependencies, #scan_service_dependencies
Methods included from SharedUtilityMethods
#app_source?, #condition_label, #detect_entry_points, #extract_action_filter_actions, #extract_callback_conditions, #extract_class_methods, #extract_class_name, #extract_custom_errors, #extract_initialize_params, #extract_namespace, #extract_parent_class, #extract_public_methods, #resolve_source_location, #skip_file?
Constructor Details
#initialize ⇒ ActionCableExtractor
Returns a new instance of ActionCableExtractor.
29 30 31 |
# File 'lib/woods/extractors/action_cable_extractor.rb', line 29 def initialize # No directories to scan — this is runtime introspection end |
Instance Method Details
#extract_all ⇒ Array<ExtractedUnit>
Extract all ActionCable channels as ExtractedUnits.
36 37 38 39 40 41 42 43 |
# File 'lib/woods/extractors/action_cable_extractor.rb', line 36 def extract_all return [] unless action_cable_available? channels = channel_descendants return [] if channels.empty? channels.filter_map { |klass| extract_channel(klass) } end |
#extract_channel(klass) ⇒ ExtractedUnit?
Extract a single channel class into an ExtractedUnit.
Public for incremental re-extraction via CLASS_BASED dispatch.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/woods/extractors/action_cable_extractor.rb', line 51 def extract_channel(klass) name = klass.name file_path = source_file_for(klass, name) source = read_source(file_path) own_methods = klass.instance_methods(false) unit = ExtractedUnit.new( type: :action_cable_channel, identifier: name, file_path: file_path ) unit.namespace = extract_namespace(name) unit.source_code = source unit. = (source, own_methods) unit.dependencies = source.empty? ? [] : scan_common_dependencies(source) unit rescue StandardError => e log_extraction_error(name, e) nil end |