New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add entry_name for kaminari #607

Open
wants to merge 1 commit into
base: master
from
Jump to file or symbol
Failed to load files and symbols.
+8 −2
Diff settings

Always

Just for now

@@ -20,8 +20,9 @@ def self.included(base)
Elasticsearch::Model::Response::Results.__send__ :include, ::Kaminari::PageScopeMethods
Elasticsearch::Model::Response::Records.__send__ :include, ::Kaminari::PageScopeMethods
Elasticsearch::Model::Response::Results.__send__ :delegate, :limit_value, :offset_value, :total_count, :max_pages, to: :response
Elasticsearch::Model::Response::Records.__send__ :delegate, :limit_value, :offset_value, :total_count, :max_pages, to: :response
methods = [:limit_value, :offset_value, :total_count, :max_pages, :entry_name]
Elasticsearch::Model::Response::Results.__send__ :delegate, *methods, to: :response
Elasticsearch::Model::Response::Records.__send__ :delegate, *methods, to: :response
base.class_eval <<-RUBY, __FILE__, __LINE__ + 1
# Define the `page` Kaminari method
@@ -95,6 +96,10 @@ def total_count
results.total
end
def entry_name
klass.entry_name
end
# Returns the models's `per_page` value or the default
#
# @api private
@@ -26,6 +26,7 @@ def self.document_type; 'bar'; end
assert_respond_to @response, :limit
assert_respond_to @response, :offset
assert_respond_to @response, :total_count
assert_respond_to @response, :entry_name
end
context "#page method" do
ProTip! Use n and p to navigate between commits in a pull request.