Class: RubyXmlMapper::FileCache
- Inherits:
-
Object
- Object
- RubyXmlMapper::FileCache
- Defined in:
- lib/ruby-xml-mapper/file_cache.rb
Overview
Copyright 2008-2009 Stanislav Senotrusov <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Instance Method Summary collapse
- #any_changes? ⇒ Boolean
- #clear ⇒ Object
- #get(filename, &block) ⇒ Object
-
#initialize ⇒ FileCache
constructor
A new instance of FileCache.
- #no_changes? ⇒ Boolean
Constructor Details
#initialize ⇒ FileCache
Returns a new instance of FileCache.
17 18 19 20 |
# File 'lib/ruby-xml-mapper/file_cache.rb', line 17 def initialize @items = {} @mutex = Mutex.new end |
Instance Method Details
#any_changes? ⇒ Boolean
30 31 32 |
# File 'lib/ruby-xml-mapper/file_cache.rb', line 30 def any_changes? !no_changes? end |
#clear ⇒ Object
40 41 42 43 44 |
# File 'lib/ruby-xml-mapper/file_cache.rb', line 40 def clear @mutex.synchronize do @items.clear end end |
#get(filename, &block) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/ruby-xml-mapper/file_cache.rb', line 22 def get filename, &block @mutex.synchronize do @items[filename] ||= RubyXmlMapper::FileCacheItem.new(filename) end @items[filename].get &block end |
#no_changes? ⇒ Boolean
34 35 36 37 38 |
# File 'lib/ruby-xml-mapper/file_cache.rb', line 34 def no_changes? @mutex.synchronize do @items.all? { |filename, item| item.no_changes? } end end |