Skip to content

Commit

Permalink
param_name configure via block
Browse files Browse the repository at this point in the history
  • Loading branch information
ajrkerr committed May 2, 2011
1 parent cde294b commit 1636a28
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
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
4 changes: 4 additions & 0 deletions lib/kaminari/config.rb
Expand Up @@ -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...?
Expand Down
12 changes: 12 additions & 0 deletions spec/config/config_spec.rb
Expand Up @@ -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

0 comments on commit 1636a28

Please sign in to comment.