namedarguments 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.txt CHANGED
@@ -3,28 +3,17 @@ NamedArguments
3
3
 
4
4
  == DESCRIPTION:
5
5
 
6
- Adds the ability to call class constructors with a hash of arguments to
7
- initialize attributes in the new object.
6
+ === Not yet ready for production.
8
7
 
9
8
  == FEATURES/PROBLEMS:
10
9
 
11
- class Snark
12
- include NamedArguments
13
-
14
- attr_accessor :color, :size, :name
15
-
16
- attribute_defaults :color => 'blue', :size => lambda {|s| some_method_call(s)}
17
- required_fields :color, :name
18
- required_respond_to :name => :to_s
19
- required_kind_of? :size => Fixnum
20
- type_conversion :size => Fixnum
21
- end
22
-
23
- s = Snark.new :boojum => 7, :color => red
10
+ == SYNOPSYS:
11
+
12
+ == REQUIREMENTS:
24
13
 
25
14
  == INSTALL:
26
15
 
27
- gem install namedarguments
16
+ sudo gem install
28
17
 
29
18
  == LICENSE:
30
19
 
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ Hoe.new('namedarguments', NamedArguments::VERSION) do |p|
6
6
  p.summary = 'Provide named arguments (hashes) to constructors to initialize attributes.'
7
7
  p.author = "James M Moore"
8
8
  p.email = 'james@phonesonrails.com'
9
- p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
9
+ # p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
10
10
  # p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
11
11
  p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
12
12
  end
@@ -1,27 +1,17 @@
1
- # Provides several hash utilities.
1
+ # Hash utilities.
2
2
  #
3
3
  # Note that you need to extend your hash with this module:
4
4
  #
5
5
  # hash = {}
6
6
  # hash.extend HashExtendedTools
7
7
  # hash = hash.exclude :foo, :bar
8
- #
9
- # Or create a new class:
10
- #
11
- # class HashWithExtendedTools < Hash
12
- # include HashExtendedTools
13
- # end
14
8
  module HashExtendedTools
15
9
  # Change keys in a hash.
16
10
  #
17
11
  # Pass in a hash of:
18
12
  #
19
- # old_key => new_key
20
- #
21
- # Any keys matching +old_key+ will be
22
- # deleted and a new entry created with
23
- # the same value and the new key.
24
- def switch_keys args = {}
13
+ # :old_key => :new_key
14
+ def switch_keys(args = {})
25
15
  args.each_pair do
26
16
  |old_key, new_key|
27
17
  if self.has_key?(old_key)
@@ -31,14 +21,6 @@ module HashExtendedTools
31
21
  end
32
22
  end
33
23
 
34
- # Return a new hash not including
35
- # keys that are contained in
36
- # +keys_to_exclude+.
37
- #
38
- # Keys that match entries in
39
- # +keys_to_exclude+ are deleted if
40
- # either they match as string or a
41
- # symbol (created with to_sym).
42
24
  def exclude *keys_to_exclude
43
25
  result = self.dup
44
26
  keys_to_exclude.each do |k|
@@ -52,9 +34,6 @@ module HashExtendedTools
52
34
  # return a hash containing
53
35
  # the key/value pairs
54
36
  # for the matching keys.
55
- #
56
- # Values that are nil are not
57
- # returned.
58
37
  def slice *slice_keys
59
38
  result = {}
60
39
  slice_keys.each do |k|
@@ -29,7 +29,7 @@ require File.dirname(__FILE__) + '/singleton_creator_mixin'
29
29
  #
30
30
  # See NamedArgumentsClassMethods for more methods.
31
31
  module NamedArguments
32
- VERSION = '0.0.1'
32
+ VERSION = '0.0.2'
33
33
 
34
34
  include HashExtendedTools
35
35
 
@@ -167,15 +167,9 @@ module NamedArguments
167
167
  end
168
168
  end
169
169
 
170
- # For every key/value pair in +args+, set the
171
- # value of the attribute +key+ to +value+.
170
+ # For every key/value pair in +args+, call:
172
171
  #
173
- # class Snark
174
- # include NamedArguments
175
- # attr_accessor :boojum
176
- # end
177
- #
178
- # s = Snark.new :boojum => 7
172
+ # self.send k,
179
173
  def initialize args = {}
180
174
  if kind_of? ActiveRecord::Base
181
175
  super
metadata CHANGED
@@ -3,15 +3,15 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: namedarguments
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.1
7
- date: 2006-12-06 00:00:00 -08:00
6
+ version: 0.0.2
7
+ date: 2006-12-05 00:00:00 -08:00
8
8
  summary: Provide named arguments (hashes) to constructors to initialize attributes.
9
9
  require_paths:
10
10
  - lib
11
11
  email: james@phonesonrails.com
12
12
  homepage: http://www.zenspider.com/ZSS/Products/namedarguments/
13
13
  rubyforge_project: namedarguments
14
- description: "Adds the ability to call class constructors with a hash of arguments to initialize attributes in the new object. == FEATURES/PROBLEMS: class Snark include NamedArguments attr_accessor :color, :size, :name attribute_defaults :color => 'blue', :size => lambda {|s| some_method_call(s)} required_fields :color, :name required_respond_to :name => :to_s required_kind_of? :size => Fixnum type_conversion :size => Fixnum end s = Snark.new :boojum => 7, :color => red == INSTALL:"
14
+ description: The author was too lazy to write a description
15
15
  autorequire:
16
16
  default_executable:
17
17
  bindir: bin