class Xcodeproj::Project::PBXObjectList
def <<(object)
def <<(object) @callback.call(object) if @callback end
def ==(other)
def ==(other) self.to_a == other.to_a end
def [](uuid)
def [](uuid) if hash = @scoped_hash[uuid] Project.const_get(hash['isa']).new(@project, uuid, hash) end end
def add(klass, hash = {})
def add(klass, hash = {}) object = klass.new(@project, nil, hash) @callback.call(object) if @callback object end
def each
def each @scoped_hash.keys.each do |uuid| yield self[uuid] end end
def empty?
def empty? @scoped_hash.empty? end
def first
def first to_a.first end
def initialize(represented_class, project, scoped, &new_object_callback)
def initialize(represented_class, project, scoped, &new_object_callback) @represented_class = represented_class @project = project @scoped_hash = scoped.is_a?(Array) ? scoped.inject({}) { |h, o| h[o.uuid] = o.attributes; h } : scoped @callback = new_object_callback end
def inspect
def inspect "<PBXObjectList: #{map(&:inspect)}>" end
def last
def last to_a.last end
def method_missing(name, *args, &block)
def method_missing(name, *args, &block) if @represented_class.respond_to?(name) object = @represented_class.send(name, @project, *args) # The callbacks are only for PBXObject instances instantiated # from the class method that we forwarded the message to. @callback.call(object) if object.is_a?(PBXObject) object else super end end
def new(hash = {})
def new(hash = {}) add(@represented_class, hash) end
def select_by_class(klass)
def select_by_class(klass) scoped = @scoped_hash.select { |_, attr| attr['isa'] == klass.isa } PBXObjectList.new(klass, @project, scoped) do |object| # Objects added to the subselection should still use the same # callback as this list. self << object end end