Sha256: e06ac474e6038bcb2b79e2b212b4b29b75609c8981ffc497bbcf1d0c053b2a94

Contents?: true

Size: 1.13 KB

Versions: 12

Compression:

Stored size: 1.13 KB

Contents

module FHIR
  module DSTU2
    class Field
      attr_accessor :name
      attr_accessor :local_name
      attr_accessor :path
      attr_accessor :type
      attr_accessor :type_profiles
      attr_accessor :min
      attr_accessor :max
      attr_accessor :valid_codes
      attr_accessor :binding
      attr_accessor :regex
      attr_accessor :constraint

      def initialize(name = '')
        @name = name
        @local_name = fix_name(@name)
        @type_profiles = []
        @valid_codes = []
      end

      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

      def fix_name(name)
        fix = nil
        fix = "local_#{name}" if %w[class method resourceType].include?(name)
        fix
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
fhir_dstu2_models-1.1.1 lib/fhir_dstu2_models/bootstrap/field.rb
fhir_dstu2_models-1.1.0 lib/fhir_dstu2_models/bootstrap/field.rb
fhir_dstu2_models-1.0.11 lib/fhir_dstu2_models/bootstrap/field.rb
fhir_dstu2_models-1.0.10 lib/fhir_dstu2_models/bootstrap/field.rb
fhir_dstu2_models-1.0.9 lib/fhir_dstu2_models/bootstrap/field.rb
fhir_dstu2_models-1.0.8 lib/fhir_dstu2_models/bootstrap/field.rb
fhir_dstu2_models-1.0.7 lib/fhir_dstu2_models/bootstrap/field.rb
fhir_dstu2_models-1.0.6 lib/fhir_dstu2_models/bootstrap/field.rb
fhir_dstu2_models-1.0.5 lib/fhir_dstu2_models/bootstrap/field.rb
fhir_dstu2_models-1.0.4 lib/fhir_dstu2_models/bootstrap/field.rb
fhir_dstu2_models-1.0.3 lib/fhir_dstu2_models/bootstrap/field.rb
fhir_dstu2_models-1.0.2 lib/fhir_dstu2_models/bootstrap/field.rb