Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Touch-ups to file and xattr stores for DRY and consistency.

  • Loading branch information...
commit 001335c8dbbe9721492465364ee5f4b7e262e78e 1 parent 6182d8d
Quin Hoxie authored
Showing with 4 additions and 8 deletions.
  1. +3 −5 lib/moneta/file.rb
  2. +1 −3 lib/moneta/xattr.rb
View
8 lib/moneta/file.rb
@@ -1,10 +1,10 @@
begin
- require "fileutils"
require "xattr"
rescue LoadError
puts "You need the xattr gem to use the File moneta store"
exit
end
+require "fileutils"
module Moneta
class File
@@ -40,7 +40,7 @@ def initialize(options = {})
if ::File.file?(@directory)
raise StandardError, "The path you supplied #{@directory} is a file"
elsif !::File.exists?(@directory)
- FileUtils.mkdir(@directory)
+ FileUtils.mkdir_p(@directory)
end
@expiration = Expiration.new(@directory)
@@ -51,9 +51,7 @@ def key?(key)
::File.exist?(path(key))
end
- def has_key?(key)
- ::File.exist?(path(key))
- end
+ alias has_key? key?
def [](key)
if ::File.exist?(path(key))
View
4 lib/moneta/xattr.rb
@@ -26,9 +26,7 @@ def key?(key)
@hash.list.include?(key)
end
- def has_key?(key)
- @hash.list.include?(key)
- end
+ alias has_key? key?
def [](key)
return nil unless key?(key)
Please sign in to comment.
Something went wrong with that request. Please try again.