Class: Progress

Inherits:
ApplicationRecord show all
Defined in:
app/models/progress.rb

Direct Known Subclasses

Assignment, Indicator

Instance Method Summary collapse

Methods inherited from ApplicationRecord

active_between, aggregate_of, all_except, defaults, #delete, #destroy!, enum_prefixed_translations_for, numbered, organic_on, resource_fields, #save, #save_and_notify!, #save_and_notify_changes!, serialize_symbolized_hash_array, teaser_on, #update_and_notify!, update_or_create!, whitelist_attributes, with_pg_retry, with_temporary_token

Methods included from WithPgLock

#with_pg_lock

Instance Method Details

#_copy_to!(organization) ⇒ Object



16
17
18
# File 'app/models/progress.rb', line 16

def _copy_to!(organization)
  dup.transfer_to!(organization)
end

#delete_duplicates_in!(organization) ⇒ Object



41
42
43
# File 'app/models/progress.rb', line 41

def delete_duplicates_in!(organization)
  duplicates_in(organization).delete_all
end

#dirty_parent_by_submission!Object



12
13
14
# File 'app/models/progress.rb', line 12

def dirty_parent_by_submission!
  parent&.dirty_by_submission!
end

#guide_indicator?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'app/models/progress.rb', line 33

def guide_indicator?
  is_a?(Indicator) && content_type == 'Guide'
end

#has_duplicates_in?(organization) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'app/models/progress.rb', line 37

def has_duplicates_in?(organization)
  duplicates_in(organization).present?
end

#parentObject



7
8
9
10
# File 'app/models/progress.rb', line 7

def parent
  assign_attributes(parent: parent_content&.progress_for(user, organization)) unless super
  super
end

#transfer_to!(organization) ⇒ Object Also known as: _move_to!



20
21
22
23
# File 'app/models/progress.rb', line 20

def transfer_to!(organization)
  update! organization: organization, parent: nil
  self
end