Skip to content

Commit

Permalink
Merge pull request #6 from ngty/no_interpolation_for_binding_evaluation
Browse files Browse the repository at this point in the history
Fix for the case when marshalled data includes "#{" when  eval'ing bindi...
  • Loading branch information
ngty committed Jun 15, 2014
2 parents 4c25dd2 + 6214e0f commit 4ab9c18
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/serializable_proc/binding.rb
Expand Up @@ -29,7 +29,7 @@ def eval!(binding = nil)
private

def declare_vars
@declare_vars ||= @vars.map{|(k,v)| "#{k} = Marshal.load(%|#{mdump(v)}|)" } * '; '
@declare_vars ||= @vars.map{|(k,v)| "#{k} = Marshal.load(%q|#{mdump(v)}|)" } * '; '
end

def bounded_val(var, binding)
Expand Down
22 changes: 11 additions & 11 deletions spec/proc_like/marshalling_spec.rb
Expand Up @@ -27,19 +27,19 @@
Marshal.load(Marshal.dump(s_proc)).call.should.equal(expected)
end

should 'handle local variables that marshal with "|" character' do
class MarshallingTestClass
attr_accessor :i
def initialize
@i = 31921
end
end

testClass = MarshallingTestClass.new
s_proc = SerializableProc.new{ testClass.i }
Marshal.load(Marshal.dump(s_proc)).call.should.equal(31921)
should 'handle local variables that marshal with "|"' do
v = {a: '|'}
s_proc = SerializableProc.new{ v[:a] }
Marshal.load(Marshal.dump(s_proc)).call.should.equal('|')
end

should 'handle local variables that marshal with "#{"' do
v = {a: '#{'}
s_proc = SerializableProc.new{ v[:a] }
Marshal.load(Marshal.dump(s_proc)).call.should.equal('#{')
end


should 'handle instance variables' do
@x, @y, expected = 'awe', 'some', 'awesome'
s_proc = SerializableProc.new{ @x + @y }
Expand Down

0 comments on commit 4ab9c18

Please sign in to comment.