Class: ThinkingSphinx::Guard::File
- Inherits:
-
Object
- Object
- ThinkingSphinx::Guard::File
- Defined in:
- lib/thinking_sphinx/guard/file.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name) ⇒ File
constructor
A new instance of File.
- #lock ⇒ Object
- #locked? ⇒ Boolean
- #path ⇒ Object
- #unlock ⇒ Object
Constructor Details
#initialize(name) ⇒ File
Returns a new instance of File.
6 7 8 |
# File 'lib/thinking_sphinx/guard/file.rb', line 6 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/thinking_sphinx/guard/file.rb', line 4 def name @name end |
Instance Method Details
#lock ⇒ Object
10 11 12 |
# File 'lib/thinking_sphinx/guard/file.rb', line 10 def lock FileUtils.touch path end |
#locked? ⇒ Boolean
14 15 16 |
# File 'lib/thinking_sphinx/guard/file.rb', line 14 def locked? File.exist? path end |
#path ⇒ Object
18 19 20 21 22 23 |
# File 'lib/thinking_sphinx/guard/file.rb', line 18 def path @path ||= File.join( ThinkingSphinx::Configuration.instance.indices_location, "ts-#{name}.tmp" ) end |
#unlock ⇒ Object
25 26 27 |
# File 'lib/thinking_sphinx/guard/file.rb', line 25 def unlock FileUtils.rm(path) if locked? end |