Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simplify push! and pop! (since they don't have to be deep any more)

  • Loading branch information...
commit 01622129cb7621beb00fbba86c0d4fb12c2064b3 1 parent 4020c35
@mbklein mbklein authored
Showing with 8 additions and 6 deletions.
  1. +8 −6 lib/confstruct/configuration.rb
View
14 lib/confstruct/configuration.rb
@@ -24,19 +24,17 @@ def configure *args, &block
end
def push! *args, &block
- (self[:@stash] ||= []).push(self.deep_copy)
+ _stash.push(self.deep_copy)
configure *args, &block if args.length > 0 or block_given?
self
end
def pop!
- s = self[:@stash]
- if s.nil? or s.empty?
+ if _stash.empty?
raise IndexError, "Stash is empty"
else
- obj = s.pop
+ obj = _stash.pop
self.clear
- self[:@stash] = s unless s.empty?
self.merge! obj
after_config! self
end
@@ -46,6 +44,10 @@ def pop!
def reset_defaults!
self.replace(default_values.deep_copy)
end
-
+
+ protected
+ def _stash
+ @stash ||= []
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.