attributes 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -45,6 +45,10 @@ SYNOPSIS
45
45
  all this in < 100 lines of code
46
46
 
47
47
  HISTORY
48
+ 4.1.0
49
+ - 4.0.0 introduced a bug where a query (foo?) would not initialize a var -
50
+ 4.1.0 fixes that
51
+
48
52
  4.0.0
49
53
  - removed dependancy on, and bundle of, pervasives
50
54
  - faster. as fast as normal method definition.
@@ -226,5 +230,37 @@ SAMPLES
226
230
 
227
231
  ~ > ruby samples/e.rb
228
232
 
229
- #<Config:0x20080 @port=80, @host="codeforpeople.org">
233
+ #<Config:0x1ffb8 @port=80, @host="codeforpeople.org">
234
+
235
+
236
+ <========< samples/f.rb >========>
237
+
238
+ ~ > cat samples/f.rb
239
+
240
+ #
241
+ # of course attributes works as well at class/module level as at instance
242
+ # level
243
+ #
244
+ require 'attributes'
245
+
246
+ module Logging
247
+ Level_names = {
248
+ 0 => 'INFO',
249
+ # ...
250
+ 42 => 'DEBUG',
251
+ }
252
+
253
+ class << self
254
+ attribute 'level' => 42
255
+ attribute('level_name'){ Level_names[level] }
256
+ end
257
+ end
258
+
259
+ p Logging.level
260
+ p Logging.level_name
261
+
262
+ ~ > ruby samples/f.rb
263
+
264
+ 42
265
+ "DEBUG"
230
266
 
@@ -45,6 +45,10 @@ SYNOPSIS
45
45
  all this in < 100 lines of code
46
46
 
47
47
  HISTORY
48
+ 4.1.0
49
+ - 4.0.0 introduced a bug where a query (foo?) would not initialize a var -
50
+ 4.1.0 fixes that
51
+
48
52
  4.0.0
49
53
  - removed dependancy on, and bundle of, pervasives
50
54
  - faster. as fast as normal method definition.
@@ -1,5 +1,5 @@
1
1
  module Attributes
2
- Attributes::VERSION = '4.0.0' unless defined? Attributes::VERSION
2
+ Attributes::VERSION = '4.1.0' unless defined? Attributes::VERSION
3
3
  def self.version() Attributes::VERSION end
4
4
 
5
5
  class List < ::Array
@@ -49,21 +49,27 @@ module Attributes
49
49
  def #{ name }=(value)
50
50
  @#{ name } = value
51
51
  end
52
+ code
52
53
 
54
+ module_eval <<-code
53
55
  def #{ name }(*value)
54
56
  return self.#{ name } = value.first unless value.empty?
55
57
  #{ name }! unless defined? @#{ name }
56
58
  @#{ name }
57
59
  end
60
+ code
58
61
 
62
+ module_eval <<-code
59
63
  def #{ name }!
60
64
  initializer = ObjectSpace._id2ref #{ initializer_id }
61
65
  self.#{ name } = initializer.call(self)
62
66
  @#{ name }
63
67
  end
68
+ code
64
69
 
70
+ module_eval <<-code
65
71
  def #{ name }?
66
- defined? @#{ name } and #{ name }
72
+ #{ name }
67
73
  end
68
74
  code
69
75
 
@@ -1,5 +1,5 @@
1
1
  module Attributes
2
- Attributes::VERSION = '4.0.0' unless defined? Attributes::VERSION
2
+ Attributes::VERSION = '4.1.0' unless defined? Attributes::VERSION
3
3
  def self.version() Attributes::VERSION end
4
4
 
5
5
  class List < ::Array
@@ -49,21 +49,27 @@ module Attributes
49
49
  def #{ name }=(value)
50
50
  @#{ name } = value
51
51
  end
52
+ code
52
53
 
54
+ module_eval <<-code
53
55
  def #{ name }(*value)
54
56
  return self.#{ name } = value.first unless value.empty?
55
57
  #{ name }! unless defined? @#{ name }
56
58
  @#{ name }
57
59
  end
60
+ code
58
61
 
62
+ module_eval <<-code
59
63
  def #{ name }!
60
64
  initializer = ObjectSpace._id2ref #{ initializer_id }
61
65
  self.#{ name } = initializer.call(self)
62
66
  @#{ name }
63
67
  end
68
+ code
64
69
 
70
+ module_eval <<-code
65
71
  def #{ name }?
66
- defined? @#{ name } and #{ name }
72
+ #{ name }
67
73
  end
68
74
  code
69
75
 
@@ -0,0 +1,21 @@
1
+ #
2
+ # of course attributes works as well at class/module level as at instance
3
+ # level
4
+ #
5
+ require 'attributes'
6
+
7
+ module Logging
8
+ Level_names = {
9
+ 0 => 'INFO',
10
+ # ...
11
+ 42 => 'DEBUG',
12
+ }
13
+
14
+ class << self
15
+ attribute 'level' => 42
16
+ attribute('level_name'){ Level_names[level] }
17
+ end
18
+ end
19
+
20
+ p Logging.level
21
+ p Logging.level_name
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: attributes
5
5
  version: !ruby/object:Gem::Version
6
- version: 4.0.0
7
- date: 2007-10-10 00:00:00 -06:00
6
+ version: 4.1.0
7
+ date: 2007-10-18 00:00:00 -06:00
8
8
  summary: attributes
9
9
  require_paths:
10
10
  - lib
@@ -34,7 +34,7 @@ files:
34
34
  - gen_readme.rb
35
35
  - install.rb
36
36
  - lib
37
- - lib/attributes-4.0.0.rb
37
+ - lib/attributes-4.1.0.rb
38
38
  - lib/attributes.rb
39
39
  - README
40
40
  - README.tmpl
@@ -44,6 +44,7 @@ files:
44
44
  - samples/c.rb
45
45
  - samples/d.rb
46
46
  - samples/e.rb
47
+ - samples/f.rb
47
48
  test_files: []
48
49
 
49
50
  rdoc_options: []