-
-
Save deathbob/322051 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#example with a formatted date and a boolean | |
xml.instruct! | |
xml.declare! :DOCTYPE, :plist, :PUBLIC, "-//Apple Computer//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd" | |
xml.plist("version" => 1.0) do |plist| | |
plist.dict do |wrapper| | |
@occasions.each do |occasion| | |
wrapper.key occasion.id | |
wrapper.dict do |dict| | |
dict.key 'ccd_remote_id' # required id from the system of record (rails db in this case) | |
dict.integer occasion.id | |
dict.key 'updated' # required updated timestamp for syncing (based on server time, not client) | |
dict.integer occasion.updated_at.to_i | |
dict.key 'date' # example of a valid date format string | |
dict.date occasion.starts_at.strftime('%Y-%m-%dT%H:%M:%SZ') | |
dict.key 'deleted' # example of passing a boolean value (which might also be nil) | |
occasion.deleted? ? dict.true : dict.false | |
dict.key 'title' | |
dict.string occasion.title | |
dict.key 'location' | |
dict.string occasion.location | |
dict.key 'type' # example of passing rails style STI behavior to Core Data | |
dict.string occasion.type.to_s | |
dict.key 'categories' # simple related data example where we flatten them to a readable string | |
dict.string occasion.categories.collect{|e| e.title}.to_sentence | |
dict.key 'body' | |
dict.string occasion.body | |
dict.key 'occasionId' | |
dict.integer occasion.id | |
dict.key 'duration' | |
dict.integer occasion.duration | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment