Module: OpenehrRails::TemplateRegistry

Extended by:
ActiveSupport::Concern
Included in:
OpenehrTemplate
Defined in:
lib/openehr_rails/template_registry.rb

Overview

Behaviour of the OpenehrTemplate registry model that stores every template (OPT or ADL) known to the host application. The install generator emits a thin ActiveRecord model including this module.

Constant Summary collapse

TEMPLATE_TYPES =
%w[operational_template archetype_template].freeze

Instance Method Summary collapse

Instance Method Details

#form_fieldsObject



56
57
58
59
60
61
# File 'lib/openehr_rails/template_registry.rb', line 56

def form_fields
  raise 'form_fields is only available for operational templates' unless operational?

  template = OpenehrRails::Opt.parse(content)
  OpenehrRails::Opt::FieldExtractor.new(template).fields
end

#generate_model_nameObject



48
49
50
# File 'lib/openehr_rails/template_registry.rb', line 48

def generate_model_name
  template_id.underscore.tr('.', '_')
end

#operational?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/openehr_rails/template_registry.rb', line 52

def operational?
  template_type == 'operational_template'
end