lib/redis-model-extension.rb in redis-model-extension-0.3.4 vs lib/redis-model-extension.rb in redis-model-extension-0.3.5
- old
+ new
@@ -213,10 +213,11 @@
#if old_args is specified, don't usi it in args hash
if args[:old_args] && args[:old_args].size > 0
self.old_args = args.delete(:old_args).symbolize_keys
end
self.args = clear_args(args)
+
return self
end
#Fixing some problems with saving nil into redis and clearing input arguments
def clear_args(args)
@@ -234,21 +235,26 @@
out_args
end
#validates required attributes
def valid?
- @error = []
+ @error ||= []
self.class.conf[:required].each do |key|
if !self.args.has_key?(key) || self.args[key].nil?
@error.push("Required #{key}")
end
end
@error.size == 0
end
+
+ #return error from validation
+ def error
+ @error ||= []
+ end
#return error from validation
def errors
- @errors
+ @error ||= []
end
#take all arguments and send them out
def to_arg
self.args.inject({}) do |output, item|
\ No newline at end of file