quick_attr 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/README +42 -0
  2. metadata +7 -16
data/README ADDED
@@ -0,0 +1,42 @@
1
+
2
+ basic usage:
3
+ require 'quick_attr';
4
+ class C
5
+ extend QuickAttr
6
+ quick_attr :name, :smell
7
+ end
8
+
9
+ #set attr by passing value
10
+ c = C.new.name("bobaloba ding-dong").smell("fishy")
11
+
12
+ #get attr by calling without args...
13
+ puts c.name # bobaloba ding-dong
14
+ puts c.smell # fishy
15
+
16
+
17
+ also, if you want an attribute that defaults to a certain class, for example an array:
18
+
19
+ class C
20
+ quick_array :monkey_poems
21
+ end
22
+
23
+ c= C.new
24
+ c.monkey_poems << "asdas sdfjg dfg alsdasdlfj sdlfkj sd"
25
+ puts c.monkey_poems.inspect
26
+ -> ["asdas sdfjg dfg alsdasdlfj sdlfkj sd"]
27
+ you can also set it like before.
28
+
29
+ c.monkey_poems(:a,:s,:d:,:f)
30
+ puts c.monkey_poems.inspect
31
+ -> [:a,:s,:d,:f]
32
+
33
+ quick_hash is also like quick_array.
34
+
35
+ quick_klass expects the first argument to be a class a creates attr which behaves like attr but defaults to klass
36
+ i.e.
37
+ class NewArray < Array; end
38
+ quick_klass NewArray, :new_array
39
+
40
+
41
+
42
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quick_attr
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dominic Tarr
@@ -19,19 +19,9 @@ date: 2010-09-10 00:00:00 +12:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
22
- description: "\t\tusage: <br>\n\
23
- \t\trequire 'quick_attr'<br>\n\
24
- \t\tclass C<br>\n\
25
- \t\t\textend QuickAttr<br>\n\
26
- \t\t\tquick_attr :name, :smell<br>\n\
27
- \t\tend<br>\n\
28
- <br>\n\
29
- \t\t#set attr by passing value<br>\n\
30
- \t\tc = C.new.name(\"bobaloba ding-dong\").smell(\"fishy\")<br>\n\
31
- <br>\n\
32
- \t\t#get attr by calling without args...<br>\n\
33
- \t\tputs c.name\t# bobaloba ding-dong<br>\n\
34
- \t\tputs c.smell\t# fishy<br>\n"
22
+ description: "\t\tchain attr methods\n\
23
+ \t\tb.name(\"billy-bob\").insane(true).gun_licence(nil);\n\
24
+ \t\tget by calling with no args: b.name == \"billy-bob\"\n"
35
25
  email: dominic.tarr@gmail.com
36
26
  executables: []
37
27
 
@@ -42,6 +32,7 @@ extra_rdoc_files: []
42
32
  files:
43
33
  - lib/quick_attr.rb
44
34
  - test/test_quick_attr.rb
35
+ - README
45
36
  has_rdoc: true
46
37
  homepage: http://github.com/dominictarr/quick_attr
47
38
  licenses: []