Module: FeatherAi::Rails::ActsAsSighting::InstanceMethods
- Defined in:
- lib/feather_ai/rails/acts_as_sighting.rb
Overview
Instance methods for bird sighting records.
Instance Method Summary collapse
Instance Method Details
#correct!(attrs) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/feather_ai/rails/acts_as_sighting.rb', line 26 def correct!(attrs) return if attrs.empty? validate_correctable_fields!(attrs.keys) update!((attrs)) end |
#corrected? ⇒ Boolean
69 70 71 |
# File 'lib/feather_ai/rails/acts_as_sighting.rb', line 69 def corrected? !corrected_at.nil? end |
#correction_delta ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/feather_ai/rails/acts_as_sighting.rb', line 73 def correction_delta return {} unless corrected? CORRECTABLE_FIELDS.each_with_object({}) do |field, delta| corrected_value = public_send(:"corrected_#{field}") next if corrected_value.nil? # NOTE: `public_send(field)` reads the original AI column, not the # corrected column, so :from always reflects the AI identification # regardless of how many times correct! has been called. delta[field] = { from: public_send(field), to: corrected_value } end end |