Skip to content

Commit

Permalink
Fix delayed attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
juanibiapina committed Jun 17, 2014
1 parent 2d26b2a commit ae61bf0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
8 changes: 0 additions & 8 deletions lib/configatron/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,7 @@ def inspect
end

def method_missing(name, *args, &block)
# In case of Configatron bugs, prevent method_missing infinite
# loops.
if @method_missing
::Kernel.raise ::NoMethodError.new("Bug in configatron; ended up in method_missing while running: #{name.inspect}")
end
@method_missing = true
do_lookup(name, *args, &block)
ensure
@method_missing = false
end

# Needed for deep_clone to actually clone this object
Expand Down
2 changes: 1 addition & 1 deletion test/functional/configatron.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Critic::Functional::ConfigatronTest < Critic::Functional::Test
@kernel.unknown
end
end

it 'responds to nil? for backward compatibility' do
refute_nil @kernel.a
end
Expand Down
18 changes: 18 additions & 0 deletions test/functional/delayed.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require_relative '_lib'

class Critic::Functional::DelayedTest < Critic::Functional::Test
before do
@kernel = Configatron::RootStore.new
end

describe 'delayed' do
before do
@kernel.a = Configatron::Delayed.new { @kernel.b }
@kernel.b = "expected"
end

it 'works independent of the order' do
assert_equal('expected', @kernel.a)
end
end
end

0 comments on commit ae61bf0

Please sign in to comment.