Class: Plist4r::PlistCache
- Defined in:
- lib/plist4r/plist_cache.rb
Instance Methods
Constructor Details
- (PlistCache) initialize(plist, *args, &blk)
A new instance of PlistCache
| 7 8 9 10 11 | # File 'lib/plist4r/plist_cache.rb', line 7 def initialize plist, *args, &blk @checksum = {} @plist = plist @backend = Backend.new plist, *args, &blk end | 
Instance Method Details
- (Object) from_string
| 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # File 'lib/plist4r/plist_cache.rb', line 13 def from_string if @from_string == @plist.from_string unless @from_string_plist_type == @plist.plist_type @from_string_plist_type = @plist.detect_plist_type end unless @from_string_file_format == @plist.file_format @plist.file_format @from_string_file_format end else @backend.call :from_string @from_string = @plist.from_string @from_string_file_format = @plist.file_format @plist.detect_plist_type unless @from_string_plist_type == @plist.plist_type @from_string_plist_type = @plist.plist_type end end @plist end | 
- (Object) needs_update_for(fmt)
| 38 39 40 | # File 'lib/plist4r/plist_cache.rb', line 38 def needs_update_for fmt @checksum[fmt] != @plist.to_hash.hash end | 
- (Object) open
| 66 67 68 69 | # File 'lib/plist4r/plist_cache.rb', line 66 def open @backend.call :open @plist end | 
- (Object) save
| 71 72 73 74 | # File 'lib/plist4r/plist_cache.rb', line 71 def save @backend.call :save @plist.filename_path end | 
- (Object) to_binary
| 50 51 52 53 54 55 56 | # File 'lib/plist4r/plist_cache.rb', line 50 def to_binary if needs_update_for(:binary) || @binary.nil? @binary = @backend.call :to_binary update_checksum_for(:binary) end @binary end | 
- (Object) to_gnustep
| 58 59 60 61 62 63 64 | # File 'lib/plist4r/plist_cache.rb', line 58 def to_gnustep if needs_update_for(:gnustep) || @gnustep.nil? @gnustep = @backend.call :to_gnustep update_checksum_for(:gnustep) end @gnustep end | 
- (Object) to_xml
| 42 43 44 45 46 47 48 | # File 'lib/plist4r/plist_cache.rb', line 42 def to_xml if needs_update_for(:xml) || @xml.nil? @xml = @backend.call :to_xml update_checksum_for(:xml) end @xml end | 
- (Object) update_checksum_for(fmt)
| 34 35 36 | # File 'lib/plist4r/plist_cache.rb', line 34 def update_checksum_for fmt @checksum[fmt] = @plist.to_hash.hash end |