Skip to content
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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down