Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

allow using Module#public with arguments

  • Loading branch information...
commit d443e6ad651bb7a55b633798254c29fc6d7b007b 1 parent 7c8826a
@rkh rkh authored
Showing with 18 additions and 1 deletion.
  1. +10 −1 lib/sinatra/base.rb
  2. +8 −0 test/settings_test.rb
View
11 lib/sinatra/base.rb
@@ -1081,6 +1081,15 @@ def condition(&block)
@conditions << block
end
+ def public=(value)
+ set :public_folder, value
+ end
+
+ def public(*)
+ super
+ public_folder
+ end
+
private
# Condition for matching host name. Parameter might be String or Regexp.
def host_name(pattern)
@@ -1411,7 +1420,7 @@ class << self
set :reload_templates, Proc.new { development? or RUBY_VERSION < '1.8.7' }
set :lock, false
- set :public, Proc.new { root && File.join(root, 'public') }
+ set :public_folder, Proc.new { root && File.join(root, 'public') }
set :static, Proc.new { public && File.exist?(public) }
error ::Exception do
View
8 test/settings_test.rb
@@ -334,6 +334,14 @@ def foo=(value)
@application.set :root, File.dirname(__FILE__)
assert @application.static?
end
+
+ it 'is possible to use Module#public' do
+ @base.send(:define_method, :foo) { }
+ @base.send(:private, :foo)
+ assert !@base.method_defined?(:foo)
+ @base.send(:public, :foo)
+ assert @base.method_defined?(:foo)
+ end
end
describe 'bind' do
Please sign in to comment.
Something went wrong with that request. Please try again.