Class: Woods::Chunking::ModelChunker Private
- Inherits:
-
Object
- Object
- Woods::Chunking::ModelChunker
- Includes:
- ChunkBuilder
- Defined in:
- lib/woods/chunking/semantic_chunker.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Chunks a model unit by semantic sections: summary, associations, validations, callbacks, scopes, methods.
Constant Summary collapse
- ASSOCIATION_PATTERN =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/^\s*(has_many|has_one|belongs_to|has_and_belongs_to_many)\b/- VALIDATION_PATTERN =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/^\s*validates?\b/- CALLBACK_ACTIONS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'(save|create|update|destroy|validation|action|commit|rollback|find|initialize|touch)'- CALLBACK_PATTERN =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/^\s*(before_|after_|around_)#{CALLBACK_ACTIONS}\b/- SCOPE_PATTERN =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/^\s*scope\s+:/- SECTION_PATTERNS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ associations: ASSOCIATION_PATTERN, validations: VALIDATION_PATTERN, callbacks: CALLBACK_PATTERN, scopes: SCOPE_PATTERN }.freeze
- SEMANTIC_SECTIONS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%i[associations validations callbacks scopes].freeze
Instance Method Summary collapse
- #chunk ⇒ Array<Chunk> private
-
#initialize(unit) ⇒ ModelChunker
constructor
private
A new instance of ModelChunker.
Constructor Details
#initialize(unit) ⇒ ModelChunker
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ModelChunker.
318 319 320 |
# File 'lib/woods/chunking/semantic_chunker.rb', line 318 def initialize(unit) @unit = unit end |
Instance Method Details
#chunk ⇒ Array<Chunk>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
323 324 325 326 |
# File 'lib/woods/chunking/semantic_chunker.rb', line 323 def chunk sections = classify_lines(@unit.source_code.lines) build_chunks(sections).reject(&:empty?) end |