Class: Labimotion::ElementKlass

Inherits:
ApplicationRecord
  • Object
show all
Includes:
GenericKlassRevisions, Workflow
Defined in:
lib/labimotion/models/element_klass.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Workflow

#split_workflow

Methods included from GenericKlassRevisions

#create_klasses_revision

Class Method Details

.gen_klasses_jsonObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/labimotion/models/element_klass.rb', line 15

def self.gen_klasses_json
  klasses = where(is_active: true, is_generic: true).order('place')&.pluck(:name) || []
rescue ActiveRecord::StatementInvalid, PG::ConnectionBad, PG::UndefinedTable
  klasses = []
ensure
  File.write(
    Rails.root.join('config', 'klasses.json'),
    klasses&.to_json || []
  )
end

Instance Method Details

#migrate_workflowObject



27
28
29
30
31
32
33
34
# File 'lib/labimotion/models/element_klass.rb', line 27

def migrate_workflow
  return if properties_template.nil? || properties_release.nil?

  return if properties_template['flow'].nil? && properties_release['flow'].nil?

  update_column(:properties_template, split_workflow(properties_template)) if properties_template['flow']
  update_column(:properties_release, split_workflow(properties_release)) if properties_release['flow']
end