Class: Cda::Base
Direct Known Subclasses
ANY, Act, AssignedAuthor, AssignedCustodian, AssignedEntity, AssociatedEntity, Authenticator, Author, AuthoringDevice, Authorization, Birthplace, ClinicalDocument, Component1, Component2, Component3, Component4, Component5, Consent, Consumable, Criterion, Custodian, CustodianOrganization, DataEnterer, Device, DocumentationOf, EncompassingEncounter, Encounter, EncounterParticipant, Entity, Entry, EntryRelationship, ExternalAct, ExternalDocument, ExternalObservation, ExternalProcedure, Guardian, HealthCareFacility, InFulfillmentOf, Informant12, InformationRecipient, IntendedRecipient, LabeledDrug, LanguageCommunication, LegalAuthenticator, Location, MaintainedEntity, ManufacturedProduct, Material, NonXMLBody, Observation, ObservationMedia, ObservationRange, Order, Organization, OrganizationPartOf, Organizer, ParentDocument, Participant1, Participant2, ParticipantRole, Patient, PatientRole, Performer1, Performer2, Person, Place, PlayingEntity, Precondition, Procedure, Product, RecordTarget, Reference, ReferenceRange, RegionOfInterest, RelatedDocument, RelatedEntity, RelatedSubject, ResponsibleParty, Section, ServiceEvent, Specimen, SpecimenRole, StrucDocCaption, StrucDocCol, StrucDocColgroup, StrucDocContent, StrucDocFootnote, StrucDocFootnoteRef, StrucDocItem, StrucDocLinkHtml, StrucDocList, StrucDocParagraph, StrucDocRenderMultiMedia, StrucDocSub, StrucDocSup, StrucDocTable, StrucDocTbody, StrucDocTd, StrucDocText, StrucDocTfoot, StrucDocTh, StrucDocThead, StrucDocTitle, StrucDocTitleContent, StrucDocTitleFootnote, StrucDocTr, StructuredBody, Subject, SubjectPerson, SubstanceAdministration, Supply
Instance Method Summary
collapse
#defaults
#check_attributes_allowed
Constructor Details
#initialize(attrs = {}) {|_self| ... } ⇒ Base
Returns a new instance of Base.
7
8
9
10
11
12
13
|
# File 'lib/cda/base.rb', line 7
def initialize(attrs = {}, &_)
attrs = {_text: attrs} if attrs.is_a?(String) && respond_to?(:_text)
raise "Can't initialize #{self.class.name} with #{attrs.class.name} (#{attrs.inspect})" unless attrs.is_a?(Hash)
attrs_with_defaults = Utility.merge_json(attrs.with_indifferent_access, defaults)
super(Utility.mk_class(attrs_with_defaults))
yield self if block_given?
end
|
Instance Method Details
#==(other) ⇒ Object
15
16
17
|
# File 'lib/cda/base.rb', line 15
def ==(other)
self.class == other.class && self.serialize == other.serialize
end
|
#mixed? ⇒ Boolean
25
26
27
|
# File 'lib/cda/base.rb', line 25
def mixed?
respond_to?(:_text)
end
|
#serialize ⇒ Object
19
20
21
22
23
|
# File 'lib/cda/base.rb', line 19
def serialize
self.class.attribute_set.each_with_object({}) do |attr, hash|
hash[attr.name] = serialize_value(self.send(attr.name))
end.merge(_type: self.class.name)
end
|
#to_s ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'lib/cda/base.rb', line 29
def to_s
if !mixed?
super
elsif _text.present?
_text
else
super
end
end
|