Permalink
Browse files

[AbstractObjectAttribute] Fix nasty bug that lead sharing the same in…

…stance as the default value of an attribute.
  • Loading branch information...
1 parent 6784808 commit b43087cb342d8d44b491e702faddf54a222b23c3 @fabiopelosin fabiopelosin committed Feb 13, 2013
Showing with 11 additions and 10 deletions.
  1. +9 −6 lib/xcodeproj/project/object_attributes.rb
  2. +2 −4 spec/spec_helper/project.rb
@@ -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.
@@ -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

0 comments on commit b43087c

Please sign in to comment.