Browse files

Convert ZFS#mountpoint to Pathname.

  • Loading branch information...
1 parent bca70a1 commit b290c10b3c534f78fdb1b92e975bf59f3fbc565f @kvs committed Feb 28, 2012
Showing with 13 additions and 2 deletions.
  1. +9 −1 lib/zfs.rb
  2. +4 −1 spec/zfs_spec.rb
View
10 lib/zfs.rb
@@ -81,6 +81,14 @@ def attribute(name, opts={})
DateTime.strptime(get(name), '%s')
end
+ when :pathname
+ define_method name do
+ Pathname(get(name))
+ end
+ define_method "#{name}=" do |value|
+ set(name, value.to_s)
+ end if opts[:edit]
+
else
puts "Unknown type '#{opts[:type]}'"
end
@@ -215,7 +223,7 @@ def create(name, opts={})
attribute :exec, type: :boolean, edit: true, inherit: true
attribute :logbias, type: :enum, edit: true, inherit: true, values: [:latency, :throughput]
attribute :mlslabel, type: :string, edit: true, inherit: true
- attribute :mountpoint, type: :string, edit: true, inherit: true
+ attribute :mountpoint, type: :pathname,edit: true, inherit: true
attribute :nbmand, type: :boolean, edit: true, inherit: true
attribute :primarycache, type: :enum, edit: true, inherit: true, values: [:all, :none, :metadata]
attribute :quota, type: :size, edit: true, values: [:none]
View
5 spec/zfs_spec.rb
@@ -81,7 +81,10 @@
it "should support custom properties"
describe ZFS::Filesystem do
- it "should convert 'mountpoint' to Pathname"
+ it "should convert 'mountpoint' to Pathname" do
+ ZFS['tank'].mountpoint.should eq Pathname("/tank")
+ end
+
it "should convert 'origin' to a ZFS::Filesystem on clones"
end
end

0 comments on commit b290c10

Please sign in to comment.