Class: OpenEHR::RM::Factory
- Inherits:
-
Object
- Object
- OpenEHR::RM::Factory
- Defined in:
- lib/openehr/rm/factory.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(cobject) ⇒ Factory
constructor
A new instance of Factory.
Constructor Details
#initialize(cobject) ⇒ Factory
6 7 8 |
# File 'lib/openehr/rm/factory.rb', line 6 def initialize(cobject) @cobject = cobject end |
Class Method Details
.create(type, **param) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/openehr/rm/factory.rb', line 11 def create(type, **param) if type.include? '_' type = type.downcase.camelize else type = type.capitalize end class_eval("#{type}Factory").create(params(param)) end |
.params(param) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/openehr/rm/factory.rb', line 20 def params(param) param.each_with_object({}) do |item, parameters| key = item.shift value = item.shift if value.instance_of? Hash parameters[key] = Factory.create(value[:_type], **value) else parameters[key] = value end end end |
Instance Method Details
#build ⇒ Object
33 34 35 |
# File 'lib/openehr/rm/factory.rb', line 33 def build Factory.create(type, params) end |