Class: FHIR::Field
- Inherits:
-
Object
- Object
- FHIR::Field
- Defined in:
- lib/fhir_models/bootstrap/field.rb
Instance Attribute Summary collapse
-
#binding ⇒ Object
Returns the value of attribute binding.
-
#constraint ⇒ Object
Returns the value of attribute constraint.
-
#local_name ⇒ Object
Returns the value of attribute local_name.
-
#max ⇒ Object
Returns the value of attribute max.
-
#min ⇒ Object
Returns the value of attribute min.
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
-
#regex ⇒ Object
Returns the value of attribute regex.
-
#type ⇒ Object
Returns the value of attribute type.
-
#type_profiles ⇒ Object
Returns the value of attribute type_profiles.
-
#valid_codes ⇒ Object
Returns the value of attribute valid_codes.
Instance Method Summary collapse
- #fix_name(name) ⇒ Object
-
#initialize(name = '') ⇒ Field
constructor
A new instance of Field.
- #serialize ⇒ Object
Constructor Details
#initialize(name = '') ⇒ Field
Returns a new instance of Field.
15 16 17 18 19 20 |
# File 'lib/fhir_models/bootstrap/field.rb', line 15 def initialize(name = '') @name = name @local_name = fix_name(@name) @type_profiles = [] @valid_codes = [] end |
Instance Attribute Details
#binding ⇒ Object
Returns the value of attribute binding.
11 12 13 |
# File 'lib/fhir_models/bootstrap/field.rb', line 11 def binding @binding end |
#constraint ⇒ Object
Returns the value of attribute constraint.
13 14 15 |
# File 'lib/fhir_models/bootstrap/field.rb', line 13 def constraint @constraint end |
#local_name ⇒ Object
Returns the value of attribute local_name.
4 5 6 |
# File 'lib/fhir_models/bootstrap/field.rb', line 4 def local_name @local_name end |
#max ⇒ Object
Returns the value of attribute max.
9 10 11 |
# File 'lib/fhir_models/bootstrap/field.rb', line 9 def max @max end |
#min ⇒ Object
Returns the value of attribute min.
8 9 10 |
# File 'lib/fhir_models/bootstrap/field.rb', line 8 def min @min end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/fhir_models/bootstrap/field.rb', line 3 def name @name end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/fhir_models/bootstrap/field.rb', line 5 def path @path end |
#regex ⇒ Object
Returns the value of attribute regex.
12 13 14 |
# File 'lib/fhir_models/bootstrap/field.rb', line 12 def regex @regex end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/fhir_models/bootstrap/field.rb', line 6 def type @type end |
#type_profiles ⇒ Object
Returns the value of attribute type_profiles.
7 8 9 |
# File 'lib/fhir_models/bootstrap/field.rb', line 7 def type_profiles @type_profiles end |
#valid_codes ⇒ Object
Returns the value of attribute valid_codes.
10 11 12 |
# File 'lib/fhir_models/bootstrap/field.rb', line 10 def valid_codes @valid_codes end |
Instance Method Details
#fix_name(name) ⇒ Object
37 38 39 40 41 |
# File 'lib/fhir_models/bootstrap/field.rb', line 37 def fix_name(name) fix = nil fix = "local_#{name}" if %w[class method resourceType].include?(name) fix end |
#serialize ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fhir_models/bootstrap/field.rb', line 22 def serialize hash = {} instance_variables.each do |v| hash[v.to_s[1..-1]] = instance_variable_get(v) end hash.delete('name') hash.keep_if do |_key, value| !value.nil? && ((value.is_a?(Hash) && !value.empty?) || (value.is_a?(Array) && !value.empty?) || (!value.is_a?(Hash) && !value.is_a?(Array)) ) end hash end |