Commit 1905f1b3 authored by Eloy Duran's avatar Eloy Duran

Add a shortcut to define multiple attribute accessors at once.

parent 971586ce
...@@ -12,6 +12,10 @@ module Pod ...@@ -12,6 +12,10 @@ module Pod
define_method("#{name}=") { |value| @attributes[attribute_name] = value } define_method("#{name}=") { |value| @attributes[attribute_name] = value }
end end
def self.attributes(*names)
names.each { |name| attribute(name) }
end
def self.has_many(plural_attr_name, options) def self.has_many(plural_attr_name, options)
klass = options[:class] klass = options[:class]
singular_attr_name = plural_attr_name.to_s[0..-2] # strip off 's' singular_attr_name = plural_attr_name.to_s[0..-2] # strip off 's'
...@@ -43,8 +47,7 @@ module Pod ...@@ -43,8 +47,7 @@ module Pod
end end
attr_reader :uuid, :attributes attr_reader :uuid, :attributes
attribute :isa attributes :isa, :name
attribute :name
def initialize(project, uuid, attributes) def initialize(project, uuid, attributes)
@project, @uuid, @attributes = project, uuid || generate_uuid, attributes @project, @uuid, @attributes = project, uuid || generate_uuid, attributes
...@@ -78,8 +81,7 @@ module Pod ...@@ -78,8 +81,7 @@ module Pod
end end
class PBXGroup < PBXObject class PBXGroup < PBXObject
attribute :sourceTree attributes :sourceTree, :children
attribute :children
def initialize(project, uuid, attributes) def initialize(project, uuid, attributes)
super super
...@@ -122,8 +124,7 @@ module Pod ...@@ -122,8 +124,7 @@ module Pod
end end
class PBXFileReference < PBXObject class PBXFileReference < PBXObject
attribute :path attributes :path, :sourceTree
attribute :sourceTree
def initialize(project, uuid, attributes) def initialize(project, uuid, attributes)
is_new = uuid.nil? is_new = uuid.nil?
...@@ -145,8 +146,7 @@ module Pod ...@@ -145,8 +146,7 @@ module Pod
end end
class PBXBuildFile < PBXObject class PBXBuildFile < PBXObject
attribute :fileRef attributes :fileRef, :settings
attribute :settings
# Takes a PBXFileReference instance and assigns its uuid to the fileRef attribute. # Takes a PBXFileReference instance and assigns its uuid to the fileRef attribute.
def file=(file) def file=(file)
...@@ -162,8 +162,7 @@ module Pod ...@@ -162,8 +162,7 @@ module Pod
class PBXBuildPhase < PBXObject class PBXBuildPhase < PBXObject
has_many :files, :class => PBXBuildFile has_many :files, :class => PBXBuildFile
attribute :buildActionMask attributes :buildActionMask, :runOnlyForDeploymentPostprocessing
attribute :runOnlyForDeploymentPostprocessing
def initialize(*) def initialize(*)
super super
...@@ -175,8 +174,7 @@ module Pod ...@@ -175,8 +174,7 @@ module Pod
end end
class PBXCopyFilesBuildPhase < PBXBuildPhase class PBXCopyFilesBuildPhase < PBXBuildPhase
attribute :dstPath attributes :dstPath, :dstSubfolderSpec
attribute :dstSubfolderSpec
def initialize(*) def initialize(*)
super super
...@@ -191,11 +189,7 @@ module Pod ...@@ -191,11 +189,7 @@ module Pod
end end
class PBXNativeTarget < PBXObject class PBXNativeTarget < PBXObject
attribute :productName attributes :productName, :productReference, :productType, :buildRules, :dependencies
attribute :productReference
attribute :productType
attribute :buildRules
attribute :dependencies
has_many :buildPhases, :class => PBXBuildPhase has_many :buildPhases, :class => PBXBuildPhase
has_one :buildConfigurationList has_one :buildConfigurationList
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment