Class: Leann::Rails::Passage
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Leann::Rails::Passage
- Defined in:
- lib/leann/rails/active_record/passage.rb
Overview
ActiveRecord model for storing passages/documents within an index
Instance Method Summary collapse
-
#inspect ⇒ String
Detailed inspection.
-
#metadata_sym ⇒ Hash
Get metadata with symbolized keys.
-
#neighbor_ids ⇒ Array<String>
Get neighbor IDs.
-
#to_h ⇒ Hash
Convert to hash for search results.
Instance Method Details
#inspect ⇒ String
Detailed inspection
50 51 52 53 |
# File 'lib/leann/rails/active_record/passage.rb', line 50 def inspect text_preview = text.length > 50 ? "#{text[0..47]}..." : text "#<Leann::Rails::Passage id=#{id} external_id=#{external_id.inspect} text=#{text_preview.inspect}>" end |
#metadata_sym ⇒ Hash
Get metadata with symbolized keys
28 29 30 |
# File 'lib/leann/rails/active_record/passage.rb', line 28 def ( || {}).transform_keys(&:to_sym) end |
#neighbor_ids ⇒ Array<String>
Get neighbor IDs
34 35 36 |
# File 'lib/leann/rails/active_record/passage.rb', line 34 def neighbor_ids neighbors || [] end |
#to_h ⇒ Hash
Convert to hash for search results
40 41 42 43 44 45 46 |
# File 'lib/leann/rails/active_record/passage.rb', line 40 def to_h { id: external_id, text: text, metadata: } end |