Class: Observ::DatasetItem
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Observ::DatasetItem
- Defined in:
- app/models/observ/dataset_item.rb
Instance Method Summary collapse
- #expected_output_preview(max_length: 100) ⇒ Object
-
#input_preview(max_length: 100) ⇒ Object
Preview helpers for UI display.
- #last_run_item ⇒ Object
-
#run_count ⇒ Object
Check if this item has been run.
Instance Method Details
#expected_output_preview(max_length: 100) ⇒ Object
26 27 28 29 30 |
# File 'app/models/observ/dataset_item.rb', line 26 def expected_output_preview(max_length: 100) return nil if expected_output.blank? text = expected_output.is_a?(Hash) ? expected_output.to_json : expected_output.to_s text.length > max_length ? "#{text[0...max_length]}..." : text end |
#input_preview(max_length: 100) ⇒ Object
Preview helpers for UI display
20 21 22 23 24 |
# File 'app/models/observ/dataset_item.rb', line 20 def input_preview(max_length: 100) return nil if input.blank? text = input.is_a?(Hash) ? input.to_json : input.to_s text.length > max_length ? "#{text[0...max_length]}..." : text end |
#last_run_item ⇒ Object
37 38 39 |
# File 'app/models/observ/dataset_item.rb', line 37 def last_run_item run_items.order(created_at: :desc).first end |
#run_count ⇒ Object
Check if this item has been run
33 34 35 |
# File 'app/models/observ/dataset_item.rb', line 33 def run_count run_items.count end |