builder 3.1.1 → 3.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -44,12 +44,16 @@ class BlankSlate
44
44
  # Hide the method named +name+ in the BlankSlate class. Don't
45
45
  # hide +instance_eval+ or any method beginning with "__".
46
46
  def hide(name)
47
- if instance_methods.include?(name._blankslate_as_name) and
48
- name !~ /^(__|instance_eval$)/
47
+ warn_level = $VERBOSE
48
+ $VERBOSE = nil
49
+ if instance_methods.include?(name._blankslate_as_name) &&
50
+ name !~ /^(__|instance_eval$)/
49
51
  @hidden_methods ||= {}
50
52
  @hidden_methods[name.to_sym] = instance_method(name)
51
53
  undef_method name
52
54
  end
55
+ ensure
56
+ $VERBOSE = warn_level
53
57
  end
54
58
 
55
59
  def find_hidden_method(name)
@@ -2,7 +2,7 @@ module Builder
2
2
  VERSION_NUMBERS = [
3
3
  VERSION_MAJOR = 3,
4
4
  VERSION_MINOR = 1,
5
- VERSION_BUILD = 1,
5
+ VERSION_BUILD = 3,
6
6
  ]
7
7
  VERSION = VERSION_NUMBERS.join(".")
8
8
  end
@@ -177,11 +177,11 @@ module Builder
177
177
  # method_missing is very slow, this speeds up document generation
178
178
  # significantly.
179
179
  def cache_method_call(sym)
180
- instance_eval <<-NEW_METHOD
181
- def #{sym.to_s}(*args, &block)
182
- tag!(:#{sym.to_s}, *args, &block)
180
+ class << self; self; end.class_eval do
181
+ define_method(sym) do |*args, &block|
182
+ tag!(sym, *args, &block)
183
183
  end
184
- NEW_METHOD
184
+ end
185
185
  end
186
186
  end
187
187
 
@@ -28,6 +28,12 @@ class TestMethodCaching < Test::Unit::TestCase
28
28
  Builder::XmlBase.cache_method_calls = true
29
29
  end
30
30
 
31
+ def test_caching_does_not_break_weird_symbols
32
+ xml = Builder::XmlMarkup.new
33
+ xml.__send__("work-order", 1)
34
+ assert_equal "<work-order>1</work-order>", xml.target!
35
+ end
36
+
31
37
  def test_method_call_caching
32
38
  xml = Builder::XmlMarkup.new
33
39
  xml.cache_me
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-06 00:00:00.000000000 Z
12
+ date: 2012-09-09 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! 'Builder provides a number of builder objects that make creating structured
15
15
  data