Skip to content

Commit

Permalink
Merge pull request kaminari#102 from ajrkerr/master.
Browse files Browse the repository at this point in the history
param_name via block
  • Loading branch information
amatsuda committed May 2, 2011
2 parents cde294b + 55427d2 commit fb52cbb
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
4 changes: 4 additions & 0 deletions 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]
Expand Down
10 changes: 10 additions & 0 deletions lib/kaminari/config.rb
Expand Up @@ -23,6 +23,16 @@ class Configuration #:nodoc:
config_accessor :left
config_accessor :right
config_accessor :param_name

def param_name
if block_given?
yield
elsif config.param_name.respond_to? :call
config.param_name.call()
else
config.param_name
end
end
end

# this is ugly. why can't we pass the default value to config_accessor...?
Expand Down
2 changes: 1 addition & 1 deletion lib/kaminari/version.rb
@@ -1,3 +1,3 @@
module Kaminari
VERSION = '0.12.3'
VERSION = '0.12.4'
end
24 changes: 24 additions & 0 deletions spec/config/config_spec.rb
Expand Up @@ -45,5 +45,29 @@
context 'by default' do
its(:param_name) { should == :page }
end

context 'configured via block' do
before do
Kaminari.configure {|c| c.param_name { :test } }
end

its(:param_name) { should == :test }

after do
Kaminari.configure {|c| c.param_name = :page }
end
end

context 'configured via config lambda/proc' 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

0 comments on commit fb52cbb

Please sign in to comment.