lib/characterizable.rb in characterizable-0.0.8 vs lib/characterizable.rb in characterizable-0.0.9
- old
+ new
@@ -47,13 +47,13 @@
memo[ary[0]] = ary[1]
end
memo
end
end
- def slice(*keys)
+ def slice(*keep)
inject(self.class.new(*survivor_args)) do |memo, ary|
- if keys.include?(ary[0])
+ if keep.include?(ary[0])
memo[ary[0]] = ary[1]
end
memo
end
end
@@ -75,9 +75,16 @@
wasted_keys.push c.name
lacking_keys.push c.prerequisite
end
end
end
+ end
+ def slice(*keep)
+ copy = self.class.new *survivor_args
+ copy.keys.each do |key|
+ copy.delete key unless keep.include? key
+ end
+ copy
end
def target
survivor_args.first
end
def []=(key, value)