Skip to content

Commit

Permalink
[AbstractObjectAttribute] Fix nasty bug that lead sharing the same in…
Browse files Browse the repository at this point in the history
…stance as the default value of an attribute.
  • Loading branch information
fabiopelosin committed Feb 13, 2013
1 parent 6784808 commit b43087c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
15 changes: 9 additions & 6 deletions lib/xcodeproj/project/object_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,21 @@ def set_value(object, new_value)
object.send("#{name}=", new_value)
end

# Convenience method that sets the value of this attribute for a
# given object to the default (if any). It makes sense only for
# `:simple` attributes.
# Convenience method that sets the value of this attribute for a given
# object to the default (if any). It makes sense only for `:simple`
# attributes.
#
# @param [AbstractObject] object
# the object for which to set the default value.
# @param [AbstractObject] object
# the object for which to set the default value.
#
# @note It is extremely important to duplicate the default values
# otherwise kittens cry!
#
# @return [void]
#
def set_default(object)
raise "[Xcodeproj] Set value called for a #{type} attribute" unless type == :simple
set_value(object, default_value) if default_value
set_value(object, default_value.dup) if default_value
end

# Checks that a given value is compatible with the attribute.
Expand Down
6 changes: 2 additions & 4 deletions spec/spec_helper/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ module Project
def self.extended(context)
context.before do
@project = Xcodeproj::Project.new
# add_disable_raise_feature_to_project!
# @target = @project.targets.new_static_library(:ios, 'Pods')
end
end

def settings(*keys)
settings = Xcodeproj::Constants::COMMON_BUILD_SETTINGS.values_at(*keys)
settings.inject({}) { |hash, h| hash.merge(h) }
end

end
end

Expand Down

0 comments on commit b43087c

Please sign in to comment.