lib/plucky/query.rb in plucky-0.3.2 vs lib/plucky/query.rb in plucky-0.3.3
- old
+ new
@@ -102,10 +102,18 @@
end
def fields(*args)
clone.tap { |query| query.options[:fields] = *args }
end
+
+ def ignore(*args)
+ set_fields(args,0)
+ end
+
+ def only(*args)
+ set_fields(args,1)
+ end
def limit(count=nil)
clone.tap { |query| query.options[:limit] = count }
end
@@ -178,7 +186,16 @@
as_nice_string = to_hash.collect do |key, value|
" #{key}: #{value.inspect}"
end.sort.join(",")
"#<#{self.class}#{as_nice_string}>"
end
+
+ private
+
+ def set_fields(field_list, value)
+ the_fields = {}
+ field_list.each {|field| the_fields[field.to_sym] = value}
+ clone.tap { |query| query.options[:fields] = the_fields}
+ end
+
end
end
\ No newline at end of file