diff --git a/CHANGELOG b/CHANGELOG index 2ccef725f..d14cf14ac 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +== 0.12.4 + +* Support for config.param_name as lambda + == 0.12.3 * Haml 3.1 Support #96 [FlyboyArt, sonic921] diff --git a/lib/kaminari/config.rb b/lib/kaminari/config.rb index d7fc44ef7..7da7744cd 100644 --- a/lib/kaminari/config.rb +++ b/lib/kaminari/config.rb @@ -23,6 +23,10 @@ class Configuration #:nodoc: config_accessor :left config_accessor :right config_accessor :param_name + + def param_name + config.param_name.respond_to?(:call) ? config.param_name.call() : config.param_name + end end # this is ugly. why can't we pass the default value to config_accessor...? diff --git a/spec/config/config_spec.rb b/spec/config/config_spec.rb index f81ff7aa3..b9e0e5502 100644 --- a/spec/config/config_spec.rb +++ b/spec/config/config_spec.rb @@ -45,5 +45,17 @@ context 'by default' do its(:param_name) { should == :page } end + + context 'configured via config block' do + before do + Kaminari.configure {|c| c.param_name = lambda { :test } } + end + + its(:param_name) { should == :test } + + after do + Kaminari.configure {|c| c.param_name = :page } + end + end end end