lib/supernova/criteria.rb in supernova-0.6.4 vs lib/supernova/criteria.rb in supernova-0.6.5

- old
+ new

@@ -80,10 +80,14 @@ def paginate(pagination_options) merge_search_options :pagination, pagination_options end + def rows(number) + merge_search_options :pagination, :per_page => number + end + def near(*coordinates) merge_search_options :geo_center, normalize_coordinates(*coordinates) end def within(distance) @@ -164,14 +168,18 @@ def current_page pagination_attribute_when_greater_zero(:page) || 1 end def per_page - pagination_attribute_when_greater_zero(:per_page) || DEFAULT_PER_PAGE + ret = self.search_options[:pagination][:per_page] if self.search_options[:pagination] + ret = DEFAULT_PER_PAGE if ret.nil? + ret end def pagination_attribute_when_greater_zero(attribute) - self.search_options[:pagination][attribute] if self.search_options[:pagination] && self.search_options[:pagination][attribute].to_i > 0 + if self.search_options[:pagination] && self.search_options[:pagination][attribute].to_i > 0 + self.search_options[:pagination][attribute] + end end def implement_in_subclass raise "implement in subclass" end \ No newline at end of file