Module: RTM::AR::IO::TOJTM::Topic
- Defined in:
- lib/rtm/activerecord/io/to_jtm.rb
Instance Method Summary collapse
- #to_jtm(*a) ⇒ Object (also: #to_json)
-
#to_jtm_hash(*a) ⇒ Object
returns the JTM representation of this topic.
- #to_jtm_ref ⇒ Object
Instance Method Details
#to_jtm(*a) ⇒ Object Also known as: to_json
40 41 42 |
# File 'lib/rtm/activerecord/io/to_jtm.rb', line 40 def to_jtm(*a) to_jtm_hash.to_json(*a) end |
#to_jtm_hash(*a) ⇒ Object
returns the JTM representation of this topic
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rtm/activerecord/io/to_jtm.rb', line 28 def to_jtm_hash(*a) j={} j['item_identifiers'] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty? j['subject_identifiers'] = subject_identifiers.map{|i| i.reference} unless subject_identifiers.empty? unless j['item_identifiers'] || j['subject_identifiers'] j['item_identifiers'] = [to_jtm_ref] end j['subject_locators'] = subject_locators.map{|i| i.reference} unless subject_locators.empty? j['names'] = names.map{|i| i.to_jtm_hash} unless names.empty? j['occurrences'] = occurrences.map{|i| i.to_jtm_hash} unless occurrences.empty? j end |
#to_jtm_ref ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/rtm/activerecord/io/to_jtm.rb', line 45 def to_jtm_ref if subject_identifiers.first return subject_identifiers.first.reference end if item_identifiers.first return item_identifiers.first.reference end "t#{id}" end |