states.rb revision 5cad3e82e8c017bc189c4cecc00541ec19a2a6e2
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger#
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger# states:
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger# * pending
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger# * downloading
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger# * processing
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger# * failed
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger# * done
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger#
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornbergermodule OntologyVersion::States
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger extend ActiveSupport::Concern
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger include StateUpdater
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger included do
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger after_save :update_state_in_ontology, if: :state_changed?
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger end
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger protected
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger def update_state_in_ontology
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger ontology.state = state.to_s
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger ontology.save!
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger end
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornberger
5cad3e82e8c017bc189c4cecc00541ec19a2a6e2Julian Kornbergerend