[Groonga-commit] ranguba/groonga-client-model at 2752f9d [master] Add entry_name for Kaminari

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Dec 12 16:15:01 JST 2016


Kouhei Sutou	2016-12-12 16:15:01 +0900 (Mon, 12 Dec 2016)

  New Revision: 2752f9d53ad223416101ca15aa7f7c354f0b7d01
  https://github.com/ranguba/groonga-client-model/commit/2752f9d53ad223416101ca15aa7f7c354f0b7d01

  Message:
    Add entry_name for Kaminari

  Modified files:
    lib/groonga_client_model/modelize.rb

  Modified: lib/groonga_client_model/modelize.rb (+11 -0)
===================================================================
--- lib/groonga_client_model/modelize.rb    2016-12-12 15:56:29 +0900 (d832bbf)
+++ lib/groonga_client_model/modelize.rb    2016-12-12 16:15:01 +0900 (842b9f1)
@@ -20,6 +20,17 @@ module GroongaClientModel
       @model_class = model_class
     end
 
+    # For Kaminari
+    def entry_name(options={})
+      model_name = @model_class.model_name
+      if options[:count] == 1
+        default = model_name.human
+      else
+        default = model_name.human.pluralize
+      end
+      model_name.human(options.reverse_merge(default: default))
+    end
+
     def records
       @modelized_records ||= super.collect do |raw_record|
         record = @model_class.new(raw_record)
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index