Skip to content
This repository has been archived by the owner on Apr 14, 2018. It is now read-only.

Commit

Permalink
Ensure that entry status is not overwritten
Browse files Browse the repository at this point in the history
Object instantiation could erroneously mark an object as dirty by
calling the standard attr_writer methods. To avoid this, call the writer
methods first and at the end of instantiation, set the object status to
clean or new.
  • Loading branch information
Adrien Thebo committed May 28, 2012
1 parent b83a0f5 commit eeceaae
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/gprov/provision/entrybase.rb
Expand Up @@ -35,8 +35,6 @@ class GProv::Provision::EntryBase
# * nothing, as in we have a fresh object.
def initialize(opts={})

@status = (opts[:status] || :new)

if opts[:connection]
@connection = opts[:connection]
else
Expand All @@ -54,6 +52,9 @@ def initialize(opts={})
else
raise ArgumentError, "unrecognized object source #{opts[:source]}"
end

# The last thing we do is mark this object with the given state
@status = (opts[:status] || :new)
end

# Takes all xmlattrs defined against this object, and a given XML
Expand Down

0 comments on commit eeceaae

Please sign in to comment.