Module: RTM::AR::IO::TOYAML::Topic
- Defined in:
- lib/rtm/activerecord/io/to_yaml.rb
Instance Method Summary collapse
- #to_yaml(*a) ⇒ Object
-
#to_yaml_hash(*a) ⇒ Object
returns the YAML representation of this topic.
- #to_yaml_ref ⇒ Object
Instance Method Details
#to_yaml(*a) ⇒ Object
39 40 41 |
# File 'lib/rtm/activerecord/io/to_yaml.rb', line 39 def to_yaml(*a) to_yaml_hash.to_yaml(*a) end |
#to_yaml_hash(*a) ⇒ Object
returns the YAML representation of this topic
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rtm/activerecord/io/to_yaml.rb', line 27 def to_yaml_hash(*a) y={} y['item_identifiers'] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty? y['subject_identifiers'] = subject_identifiers.map{|i| i.reference} unless subject_identifiers.empty? unless y['item_identifiers'] || y['subject_identifiers'] y['item_identifiers'] = [to_yaml_ref] end y['subject_locators'] = subject_locators.map{|i| i.reference} unless subject_locators.empty? y['names'] = names.map{|i| i.to_yaml_hash} unless names.empty? y['occurrences'] = occurrences.map{|i| i.to_yaml_hash} unless occurrences.empty? y end |
#to_yaml_ref ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/rtm/activerecord/io/to_yaml.rb', line 42 def to_yaml_ref if subject_identifiers.first return subject_identifiers.first.reference end if item_identifiers.first return item_identifiers.first.reference end "t#{id}" end |