fattr 1.0.1 → 1.0.2
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 +51 -5
- data/README.tmpl +25 -4
- data/lib/fattr.rb +17 -1
- data/samples/g.rb +15 -0
- metadata +3 -2
data/README
CHANGED
@@ -10,9 +10,11 @@ URIS
|
|
10
10
|
http://codeforpeople.rubyforge.org/svn/
|
11
11
|
|
12
12
|
SYNOPSIS
|
13
|
-
fattr.rb is a "fatter attr" for ruby.
|
14
|
-
|
15
|
-
|
13
|
+
fattr.rb is a "fatter attr" for ruby.
|
14
|
+
|
15
|
+
fattr.rb supercedes attributes.rb as that library, even though it added only
|
16
|
+
one method to the global namespace, collided too frequently with user code -
|
17
|
+
in particular rails' code.
|
16
18
|
|
17
19
|
the implementation of fattr.rb borrows many of the best ideas from the
|
18
20
|
metakoans.rb ruby quiz
|
@@ -46,10 +48,29 @@ SYNOPSIS
|
|
46
48
|
- block caching, calling an fattr with a block sets the instance
|
47
49
|
variable to that block
|
48
50
|
|
51
|
+
- shortcuts for adding class/module level fattrs
|
52
|
+
|
49
53
|
all this in < 100 lines of code
|
50
54
|
|
51
55
|
HISTORY
|
52
|
-
|
56
|
+
1.0.2:
|
57
|
+
added Fattr shortcut for adding class/module level fattrs
|
58
|
+
|
59
|
+
class C
|
60
|
+
Fattr 'children' => []
|
61
|
+
|
62
|
+
def C.inherited other
|
63
|
+
(children << other).uniq!
|
64
|
+
super
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class B < C
|
69
|
+
end
|
70
|
+
|
71
|
+
p C.children #=> B
|
72
|
+
|
73
|
+
1.0.0:
|
53
74
|
port from attributes.rb retaining all the same features of that version of
|
54
75
|
attributes.rb
|
55
76
|
|
@@ -216,7 +237,7 @@ SAMPLES
|
|
216
237
|
|
217
238
|
~ > ruby samples/e.rb
|
218
239
|
|
219
|
-
#<Config:
|
240
|
+
#<Config:0x224d4 @port=80, @host="codeforpeople.org">
|
220
241
|
|
221
242
|
|
222
243
|
<========< samples/f.rb >========>
|
@@ -250,3 +271,28 @@ SAMPLES
|
|
250
271
|
42
|
251
272
|
"DEBUG"
|
252
273
|
|
274
|
+
|
275
|
+
<========< samples/g.rb >========>
|
276
|
+
|
277
|
+
~ > cat samples/g.rb
|
278
|
+
|
279
|
+
#
|
280
|
+
# you can add class/module fattrs the 'normal' way or using the provided
|
281
|
+
# shortcut method
|
282
|
+
#
|
283
|
+
require 'fattr'
|
284
|
+
|
285
|
+
class C
|
286
|
+
class << self
|
287
|
+
fattr 'a' => 4
|
288
|
+
end
|
289
|
+
|
290
|
+
Fattr 'b' => 2
|
291
|
+
end
|
292
|
+
|
293
|
+
p [ C.a, C.b ].join
|
294
|
+
|
295
|
+
~ > ruby samples/g.rb
|
296
|
+
|
297
|
+
"42"
|
298
|
+
|
data/README.tmpl
CHANGED
@@ -10,9 +10,11 @@ URIS
|
|
10
10
|
http://codeforpeople.rubyforge.org/svn/
|
11
11
|
|
12
12
|
SYNOPSIS
|
13
|
-
fattr.rb is a "fatter attr" for ruby.
|
14
|
-
|
15
|
-
|
13
|
+
fattr.rb is a "fatter attr" for ruby.
|
14
|
+
|
15
|
+
fattr.rb supercedes attributes.rb as that library, even though it added only
|
16
|
+
one method to the global namespace, collided too frequently with user code -
|
17
|
+
in particular rails' code.
|
16
18
|
|
17
19
|
the implementation of fattr.rb borrows many of the best ideas from the
|
18
20
|
metakoans.rb ruby quiz
|
@@ -46,10 +48,29 @@ SYNOPSIS
|
|
46
48
|
- block caching, calling an fattr with a block sets the instance
|
47
49
|
variable to that block
|
48
50
|
|
51
|
+
- shortcuts for adding class/module level fattrs
|
52
|
+
|
49
53
|
all this in < 100 lines of code
|
50
54
|
|
51
55
|
HISTORY
|
52
|
-
|
56
|
+
1.0.2:
|
57
|
+
added Fattr shortcut for adding class/module level fattrs
|
58
|
+
|
59
|
+
class C
|
60
|
+
Fattr 'children' => []
|
61
|
+
|
62
|
+
def C.inherited other
|
63
|
+
(children << other).uniq!
|
64
|
+
super
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class B < C
|
69
|
+
end
|
70
|
+
|
71
|
+
p C.children #=> B
|
72
|
+
|
73
|
+
1.0.0:
|
53
74
|
port from attributes.rb retaining all the same features of that version of
|
54
75
|
attributes.rb
|
55
76
|
|
data/lib/fattr.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Fattr
|
2
|
-
Fattr::VERSION = '1.0.
|
2
|
+
Fattr::VERSION = '1.0.2' unless Fattr.const_defined?(:VERSION)
|
3
3
|
def self.version() Fattr::VERSION end
|
4
4
|
|
5
5
|
class List < ::Array
|
@@ -111,6 +111,22 @@ end
|
|
111
111
|
|
112
112
|
class Module
|
113
113
|
include Fattr
|
114
|
+
|
115
|
+
def Fattrs(*a, &b)
|
116
|
+
class << self
|
117
|
+
self
|
118
|
+
end.module_eval do
|
119
|
+
fattrs(*a, &b)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def Fattr(*a, &b)
|
124
|
+
class << self
|
125
|
+
self
|
126
|
+
end.module_eval do
|
127
|
+
fattr(*a, &b)
|
128
|
+
end
|
129
|
+
end
|
114
130
|
end
|
115
131
|
|
116
132
|
class Object
|
data/samples/g.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fattr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ara T. Howard
|
@@ -9,7 +9,7 @@ autorequire: fattr
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-03-07 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -36,6 +36,7 @@ files:
|
|
36
36
|
- samples/d.rb
|
37
37
|
- samples/e.rb
|
38
38
|
- samples/f.rb
|
39
|
+
- samples/g.rb
|
39
40
|
has_rdoc: false
|
40
41
|
homepage: http://codeforpeople.com/lib/ruby/fattr/
|
41
42
|
post_install_message:
|