class OpenEHR::RM::Factory

Public Class Methods

create(type, *param) click to toggle source
# File lib/openehr/rm/factory.rb, line 11
def create(type, *param)
  type = type.downcase.camelize if type.include? '_'
  class_eval("#{type}Factory").create(*param)
end
new(cobject) click to toggle source
# File lib/openehr/rm/factory.rb, line 6
def initialize(cobject)
  @cobject = cobject
end

Public Instance Methods

build() click to toggle source
# File lib/openehr/rm/factory.rb, line 17
def build
  Factory.create(type, params)
end

Private Instance Methods

name() click to toggle source
# File lib/openehr/rm/factory.rb, line 26
def name
  OpenEHR::RM::DataTypes::Text::DvText.new(value: ' ')
end
params() click to toggle source
# File lib/openehr/rm/factory.rb, line 30
def params
  @cobject.attributes.inject({}) do |hash, attribute|
    if attribute.children
      hash[attribute.rm_attribute_name.to_sym] =
        attribute.children.map { |child| Factory.new(child).build }
    end
    hash
  end.merge(
  { archetype_node_id: @cobject.node_id,
    occurrences: @cobject.occurrences })
end
type() click to toggle source
# File lib/openehr/rm/factory.rb, line 22
def type
  @cobject.rm_type_name
end