From null at cozmixng.org Thu Mar 8 12:21:10 2012 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 08 Mar 2012 21:21:10 +0900 Subject: [activeldap-commit] activeldap/activeldap [master] Merge pull request #37 from white-n-az/will_paginate_integration Message-ID: <20120308122117.110959A0A7@jenkins.clear-code.com> Kouhei Sutou 2012-03-08 21:21:10 +0900 (Thu, 08 Mar 2012) New Revision: e0f1377406acc9146210f136ed1dc4e5f52cdce5 Log: Merge pull request #37 from white-n-az/will_paginate_integration changed lib/active_ldap/operations.rb to add 'offset' for will_paginate ... Patch by Craig White. Thanks!!! From null at cozmixng.org Wed Mar 7 16:01:09 2012 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 08 Mar 2012 01:01:09 +0900 Subject: [activeldap-commit] activeldap/activeldap [master] changed lib/active_ldap/operations.rb to add 'offset' for will_paginate happiness Message-ID: <20120308122116.E70DE9A0A5@jenkins.clear-code.com> Craig White 2012-03-08 01:01:09 +0900 (Thu, 08 Mar 2012) New Revision: de6f7464b28f68e2c49a538584f72f24e95f7e28 Merged e0f1377: Merge pull request #37 from white-n-az/will_paginate_integration Log: changed lib/active_ldap/operations.rb to add 'offset' for will_paginate happiness Modified files: lib/active_ldap/operations.rb Modified: lib/active_ldap/operations.rb (+3 -1) =================================================================== --- lib/active_ldap/operations.rb 2012-02-06 20:47:31 +0900 (20b735c) +++ lib/active_ldap/operations.rb 2012-03-08 01:01:09 +0900 (308fdd5) @@ -22,7 +22,7 @@ module ActiveLdap module Common VALID_SEARCH_OPTIONS = [:attribute, :value, :filter, :prefix, :classes, :scope, :limit, :attributes, - :sort_by, :order, :connection, :base] + :sort_by, :order, :connection, :base, :offset] def search(options={}, &block) validate_search_options(options) @@ -280,6 +280,7 @@ module ActiveLdap sort_by = options.delete(:sort_by) || self.sort_by order = options.delete(:order) || self.order limit = options.delete(:limit) if sort_by or order + offset = options.delete(:offset) || offset options[:attributes] |= ["objectClass"] if options[:attributes] results = search(options).collect do |dn, attrs| @@ -295,6 +296,7 @@ module ActiveLdap end results.reverse! if normalize_sort_order(order || "ascend") == :descend + results = results[offset, results.size] if offset results = results[0, limit] if limit results end