Class: QDM::Code
- Inherits:
-
Object
- Object
- QDM::Code
- Defined in:
- app/models/qdm/basetypes/code.rb
Overview
Represents a Code
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#display ⇒ Object
Returns the value of attribute display.
-
#system ⇒ Object
Returns the value of attribute system.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
-
.demongoize(object) ⇒ Object
Get the object as it was stored in the database, and instantiate this custom class from it.
-
.evolve(object) ⇒ Object
Converts the object that was supplied to a criteria and converts it into a database friendly form.
-
.mongoize(object) ⇒ Object
Takes any possible object and converts it to how it would be stored in the database.
Instance Method Summary collapse
-
#initialize(code, sys, display = nil, version = nil) ⇒ Code
constructor
Code and code system are required (at minimum).
-
#mongoize ⇒ Object
Converts an object of this instance into a database friendly value.
Constructor Details
#initialize(code, sys, display = nil, version = nil) ⇒ Code
Code and code system are required (at minimum).
7 8 9 10 11 12 |
# File 'app/models/qdm/basetypes/code.rb', line 7 def initialize(code, sys, display = nil, version = nil) @code = code @system = sys @display = display @version = version end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
4 5 6 |
# File 'app/models/qdm/basetypes/code.rb', line 4 def code @code end |
#display ⇒ Object
Returns the value of attribute display.
4 5 6 |
# File 'app/models/qdm/basetypes/code.rb', line 4 def display @display end |
#system ⇒ Object
Returns the value of attribute system.
4 5 6 |
# File 'app/models/qdm/basetypes/code.rb', line 4 def system @system end |
#version ⇒ Object
Returns the value of attribute version.
4 5 6 |
# File 'app/models/qdm/basetypes/code.rb', line 4 def version @version end |
Class Method Details
.demongoize(object) ⇒ Object
Get the object as it was stored in the database, and instantiate this custom class from it.
The array elements in demongoize are the same 5 elements used in mongoize, i.e. [ code, system, display, version ].
25 26 27 28 29 30 |
# File 'app/models/qdm/basetypes/code.rb', line 25 def demongoize(object) return nil unless object object = object.symbolize_keys QDM::Code.new(object[:code], object[:system], object[:display], object[:version]) end |
.evolve(object) ⇒ Object
Converts the object that was supplied to a criteria and converts it into a database friendly form.
47 48 49 50 51 52 |
# File 'app/models/qdm/basetypes/code.rb', line 47 def evolve(object) case object when QDM::Code then object.mongoize else object end end |
.mongoize(object) ⇒ Object
Takes any possible object and converts it to how it would be stored in the database.
34 35 36 37 38 39 40 41 42 43 |
# File 'app/models/qdm/basetypes/code.rb', line 34 def mongoize(object) case object when nil then nil when QDM::Code then object.mongoize when Hash object = object.symbolize_keys QDM::Code.new(object[:code], object[:system], object[:display], object[:version]).mongoize else object end end |
Instance Method Details
#mongoize ⇒ Object
Converts an object of this instance into a database friendly value.
15 16 17 |
# File 'app/models/qdm/basetypes/code.rb', line 15 def mongoize { code: @code, system: @system, display: @display, version: @version, _type: 'QDM::Code' } end |