Skip to content

Commit

Permalink
Added array_attribute metacommand.
Browse files Browse the repository at this point in the history
Explicitly marked attributes that take arrays.


git-svn-id: http://rubygems.rubyforge.org/svn/trunk@714 3d4018f9-ac1a-0410-99e9-8a154d859a19
  • Loading branch information
jimweirich committed Dec 29, 2004
1 parent e776016 commit 4b21e0d
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions rubygems/lib/rubygems/specification.rb
Expand Up @@ -127,6 +127,18 @@ def self.attribute(name, default=nil)
attr_accessor(name)
end

# Same as :attribute, but ensures that values assigned to the
# attribute are array values by applying :to_a to the value.
def self.array_attribute(name, default=nil)
attribute(name, default)
remove_method "#{name}="
module_eval %{
def #{name}=(value)
@#{name} = value.to_a
end
}
end

# Same as attribute above, but also records this attribute as mandatory.
def self.required_attribute(*args)
@@required_attributes << args.first
Expand Down Expand Up @@ -207,15 +219,15 @@ def warn_deprecated(old, new)
attribute :has_rdoc, false
attribute :required_ruby_version, Gem::Version::Requirement.default
attribute :platform, Gem::Platform::RUBY
attribute :authors, []
attribute :files, []
attribute :test_files, []
attribute :rdoc_options, []
attribute :extra_rdoc_files, []
attribute :executables, []
attribute :extensions, []
attribute :requirements, []
attribute :dependencies, []
array_attribute :authors, []
array_attribute :files, []
array_attribute :test_files, []
array_attribute :rdoc_options, []
array_attribute :extra_rdoc_files, []
array_attribute :executables, []
array_attribute :extensions, []
array_attribute :requirements, []
array_attribute :dependencies, []

read_only :dependencies

Expand Down

0 comments on commit 4b21e0d

Please sign in to comment.