hash-hooked 1.1.2 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,12 @@
1
1
 
2
- == 6/15/2012
2
+ ## 6/15/2012 ##
3
3
 
4
4
  Initial release - split from compositing-hash.
5
5
 
6
- == 6/30/2012
6
+ ## 6/30/2012 ##
7
7
 
8
8
  Renamed from hooked-hash to hash-hooked. File schema updated to reflect gem name.
9
+
10
+ ## 2/15/2013 ##
11
+
12
+ Minor update for initialization args to match Hash.
@@ -9,16 +9,30 @@ module ::Hash::Hooked::HashInterface
9
9
  # initialize #
10
10
  ################
11
11
 
12
+ ###
12
13
  # Initialize with reference a configuration instance.
13
- # @param [Object] object Object that HookedHash instance is attached to, primarily useful for
14
- # reference from hooks.
15
- # @param [Hash<Object>] args Parameters passed through super to Hash#initialize.
16
- # @return [true,false] Whether receiver identifies as object.
17
- def initialize( configuration_instance = nil, *args )
14
+ #
15
+ # @overload initialize( configuration_instance, hash_initialization_arg, ... )
16
+ #
17
+ # @param [Object] configuration_instance
18
+ #
19
+ # Object that instance will be attached to; primarily useful for reference from hooks.
20
+ #
21
+ # @param [Object] hash_initialization_arg
22
+ #
23
+ # Parameters passed through super to Hash#initialize.
24
+ #
25
+ def initialize( configuration_instance = nil, default_value = nil, & default_value_block )
18
26
 
19
27
  @configuration_instance = configuration_instance
20
-
21
- super( *args )
28
+
29
+ if default_value
30
+ super( default_value )
31
+ elsif default_value_block
32
+ super( & default_value_block )
33
+ else
34
+ super()
35
+ end
22
36
 
23
37
  end
24
38
 
@@ -26,6 +40,13 @@ module ::Hash::Hooked::HashInterface
26
40
  # configuration_instance #
27
41
  ############################
28
42
 
43
+ ###
44
+ # @!attribute [r]
45
+ #
46
+ # @return [Object]
47
+ #
48
+ # Object that instance is attached to; primarily useful for reference from hooks.
49
+ #
29
50
  attr_accessor :configuration_instance
30
51
 
31
52
  ###################################### Subclass Hooks ##########################################
@@ -34,10 +55,21 @@ module ::Hash::Hooked::HashInterface
34
55
  # pre_set_hook #
35
56
  ##################
36
57
 
58
+ ###
37
59
  # A hook that is called before setting a value; return value is used in place of object.
38
- # @param [Object] key Key where object is to be stored.
39
- # @param [Object] object Element being stored.
40
- # @return [true,false] Return value is used in place of object.
60
+ #
61
+ # @param [Object] key
62
+ #
63
+ # Key where object is to be stored.
64
+ #
65
+ # @param [Object] object
66
+ #
67
+ # Element being stored.
68
+ #
69
+ # @return [true,false]
70
+ #
71
+ # Return value is used in place of object.
72
+ #
41
73
  def pre_set_hook( key, object )
42
74
 
43
75
  return object
@@ -48,10 +80,21 @@ module ::Hash::Hooked::HashInterface
48
80
  # post_set_hook #
49
81
  ###################
50
82
 
83
+ ###
51
84
  # A hook that is called after setting a value.
52
- # @param [Object] key Key where object is to be stored.
53
- # @param [Object] object Element being stored.
54
- # @return [Object] Ignored.
85
+ #
86
+ # @param [Object] key
87
+ #
88
+ # Key where object is to be stored.
89
+ #
90
+ # @param [Object] object
91
+ #
92
+ # Element being stored.
93
+ #
94
+ # @return [Object]
95
+ #
96
+ # Ignored.
97
+ #
55
98
  def post_set_hook( key, object )
56
99
 
57
100
  return object
@@ -62,9 +105,17 @@ module ::Hash::Hooked::HashInterface
62
105
  # pre_get_hook #
63
106
  ##################
64
107
 
108
+ ###
65
109
  # A hook that is called before getting a value; if return value is false, get does not occur.
66
- # @param [Object] key Key where object is to be stored.
67
- # @return [true,false] If return value is false, get does not occur.
110
+ #
111
+ # @param [Object] key
112
+ #
113
+ # Key where object is to be retrieved.
114
+ #
115
+ # @return [true,false]
116
+ #
117
+ # If return value is false, get does not occur.
118
+ #
68
119
  def pre_get_hook( key )
69
120
 
70
121
  return true
@@ -75,10 +126,21 @@ module ::Hash::Hooked::HashInterface
75
126
  # post_get_hook #
76
127
  ###################
77
128
 
129
+ ###
78
130
  # A hook that is called after getting a value.
79
- # @param [Object] key Key where object is to be stored.
80
- # @param [Object] object Element being stored.
81
- # @return [Object] Object returned in place of get result.
131
+ #
132
+ # @param [Object] key
133
+ #
134
+ # Key where object has been retrieved.
135
+ #
136
+ # @param [Object] object
137
+ #
138
+ # Element retrieved.
139
+ #
140
+ # @return [Object]
141
+ #
142
+ # Object returned in place of get result.
143
+ #
82
144
  def post_get_hook( key, object )
83
145
 
84
146
  return object
@@ -89,9 +151,17 @@ module ::Hash::Hooked::HashInterface
89
151
  # pre_delete_hook #
90
152
  #####################
91
153
 
154
+ ###
92
155
  # A hook that is called before deleting a value; if return value is false, delete does not occur.
93
- # @param [Object] key Key where object is to be stored.
94
- # @return [true,false] If return value is false, delete does not occur.
156
+ #
157
+ # @param [Object] key
158
+ #
159
+ # Key where object is to be deleted.
160
+ #
161
+ # @return [true,false]
162
+ #
163
+ # If return value is false, delete does not occur.
164
+ #
95
165
  def pre_delete_hook( key )
96
166
 
97
167
  return true
@@ -102,10 +172,21 @@ module ::Hash::Hooked::HashInterface
102
172
  # post_delete_hook #
103
173
  ######################
104
174
 
175
+ ###
105
176
  # A hook that is called after deleting a value.
106
- # @param [Object] key Key where object is to be stored.
107
- # @param [Object] object Element deleted.
108
- # @return [Object] Object returned in place of delete result.
177
+ #
178
+ # @param [Object] key
179
+ #
180
+ # Key where object has been deleted.
181
+ #
182
+ # @param [Object] object
183
+ #
184
+ # Element deleted.
185
+ #
186
+ # @return [Object]
187
+ #
188
+ # Object returned in place of delete result.
189
+ #
109
190
  def post_delete_hook( key, object )
110
191
 
111
192
  return object
@@ -146,9 +227,17 @@ module ::Hash::Hooked::HashInterface
146
227
  # get_without_hooks #
147
228
  #######################
148
229
 
149
- # Alias to :[] that bypasses hooks.
150
- # @param [Object] key Key where object is to be stored.
151
- # @return [Object] Element returned.
230
+ ###
231
+ # Alias to #[] that bypasses hooks.
232
+ #
233
+ # @param [Object] key
234
+ #
235
+ # Key where object is to be stored.
236
+ #
237
+ # @return [Object]
238
+ #
239
+ # Object retrieved.
240
+ #
152
241
  def get_without_hooks( key )
153
242
 
154
243
  @without_hooks = true
@@ -187,10 +276,21 @@ module ::Hash::Hooked::HashInterface
187
276
  # store_without_hooks #
188
277
  #########################
189
278
 
190
- # Alias to :[]= that bypasses hooks.
191
- # @param [Object] key Key where object is to be stored.
192
- # @param [Object] object Element being set.
193
- # @return [Object] Element returned.
279
+ ###
280
+ # Alias to #[]= that bypasses hooks.
281
+ #
282
+ # @param [Object] key
283
+ #
284
+ # Key where object is to be stored.
285
+ #
286
+ # @param [Object] object
287
+ #
288
+ # Element being stored.
289
+ #
290
+ # @return [Object]
291
+ #
292
+ # Element returned.
293
+ #
194
294
  def store_without_hooks( key, object )
195
295
 
196
296
  @without_hooks = true
@@ -235,9 +335,17 @@ module ::Hash::Hooked::HashInterface
235
335
  # delete_without_hooks #
236
336
  ##########################
237
337
 
238
- # Alias to :delete that bypasses hooks.
239
- # @param [Object] object Element being deleted.
240
- # @return [Object] Element returned.
338
+ ###
339
+ # Alias to #delete that bypasses hooks.
340
+ #
341
+ # @param [Object] object
342
+ #
343
+ # Element being deleted.
344
+ #
345
+ # @return [Object]
346
+ #
347
+ # Element returned.
348
+ #
241
349
  def delete_without_hooks( key )
242
350
 
243
351
  @without_hooks = true
@@ -274,9 +382,17 @@ module ::Hash::Hooked::HashInterface
274
382
  # delete_if_without_hooks #
275
383
  #############################
276
384
 
277
- # Alias to :delete_if that bypasses hooks.
278
- # @yield Block passed to :delete_if.
279
- # @return [Object] Deleted element.
385
+ ###
386
+ # Alias to #delete_if that bypasses hooks.
387
+ #
388
+ # @yield
389
+ #
390
+ # Block passed to :delete_if.
391
+ #
392
+ # @return [Object]
393
+ #
394
+ # Deleted element.
395
+ #
280
396
  def delete_if_without_hooks( & block )
281
397
 
282
398
  @without_hooks = true
@@ -312,9 +428,17 @@ module ::Hash::Hooked::HashInterface
312
428
  # reject_without_hooks! #
313
429
  ###########################
314
430
 
315
- # Alias to :reject that bypasses hooks.
316
- # @yield Block passed to :keep_if.
317
- # @return [Object] Self.
431
+ ###
432
+ # Alias to #reject that bypasses hooks.
433
+ #
434
+ # @yield
435
+ #
436
+ # Block passed to :keep_if.
437
+ #
438
+ # @return [Object]
439
+ #
440
+ # Self.
441
+ #
318
442
  def reject_without_hooks!
319
443
 
320
444
  @without_hooks = true
@@ -352,9 +476,17 @@ module ::Hash::Hooked::HashInterface
352
476
  # keep_if_without_hooks #
353
477
  ###########################
354
478
 
355
- # Alias to :keep_if that bypasses hooks.
356
- # @yield Block passed to :keep_if.
357
- # @return [Object] Deleted element.
479
+ ###
480
+ # Alias to #keep_if that bypasses hooks.
481
+ #
482
+ # @yield
483
+ #
484
+ # Block passed to :keep_if.
485
+ #
486
+ # @return [Object]
487
+ #
488
+ # Deleted element.
489
+ #
358
490
  def keep_if_without_hooks( & block )
359
491
 
360
492
  @without_hooks = true
@@ -392,9 +524,17 @@ module ::Hash::Hooked::HashInterface
392
524
  # select_without_hooks! #
393
525
  ###########################
394
526
 
395
- # Alias to :select that bypasses hooks.
396
- # @yield Block passed to :select!.
397
- # @return [Object] Self.
527
+ ###
528
+ # Alias to #select that bypasses hooks.
529
+ #
530
+ # @yield
531
+ #
532
+ # Block passed to :select!.
533
+ #
534
+ # @return [Object]
535
+ #
536
+ # Self.
537
+ #
398
538
  def select_without_hooks!( & block )
399
539
 
400
540
  @without_hooks = true
@@ -433,8 +573,13 @@ module ::Hash::Hooked::HashInterface
433
573
  # update_without_hooks #
434
574
  ##########################
435
575
 
436
- # Alias to :merge! that bypasses hooks.
437
- # @return [Object] Self.
576
+ ###
577
+ # Alias to #merge! that bypasses hooks.
578
+ #
579
+ # @return [Object]
580
+ #
581
+ # Self.
582
+ #
438
583
  def merge_without_hooks!
439
584
 
440
585
  @without_hooks = true
@@ -469,9 +614,17 @@ module ::Hash::Hooked::HashInterface
469
614
  # replace_without_hooks #
470
615
  ###########################
471
616
 
472
- # Alias to :replace that bypasses hooks.
473
- # @param [Array] other_array Other array to replace self with.
474
- # @return [Object] Self.
617
+ ###
618
+ # Alias to #replace that bypasses hooks.
619
+ #
620
+ # @param [Array] other_hash
621
+ #
622
+ # Other hash to replace self with.
623
+ #
624
+ # @return [Object]
625
+ #
626
+ # Self.
627
+ #
475
628
  def replace_without_hooks( other_hash )
476
629
 
477
630
  @without_hooks = true
@@ -503,8 +656,13 @@ module ::Hash::Hooked::HashInterface
503
656
  # shift_without_hooks #
504
657
  #########################
505
658
 
506
- # Alias to :shift that bypasses hooks.
507
- # @return [Object] Self.
659
+ ###
660
+ # Alias to #shift that bypasses hooks.
661
+ #
662
+ # @return [Object]
663
+ #
664
+ # Element shifted.
665
+ #
508
666
  def shift_without_hooks
509
667
 
510
668
  @without_hooks = true
@@ -533,8 +691,13 @@ module ::Hash::Hooked::HashInterface
533
691
  # clear_without_hooks #
534
692
  #########################
535
693
 
536
- # Alias to :clear that bypasses hooks.
537
- # @return [Object] Self.
694
+ ###
695
+ # Alias to #clear that bypasses hooks.
696
+ #
697
+ # @return [Object]
698
+ #
699
+ # Self.
700
+ #
538
701
  def clear_without_hooks
539
702
 
540
703
  @without_hooks = true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash-hooked
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-22 00:00:00.000000000 Z
12
+ date: 2013-02-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: identifies_as
@@ -41,7 +41,7 @@ files:
41
41
  - lib/hash-hooked.rb
42
42
  - spec/hash/hooked_spec.rb
43
43
  - README.md
44
- - CHANGELOG.rdoc
44
+ - CHANGELOG.md
45
45
  homepage: http://rubygems.org/gems/hash-hooked
46
46
  licenses: []
47
47
  post_install_message:
@@ -62,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
62
  version: '0'
63
63
  requirements: []
64
64
  rubyforge_project: hash-hooked
65
- rubygems_version: 1.8.23
65
+ rubygems_version: 1.8.24
66
66
  signing_key:
67
67
  specification_version: 3
68
68
  summary: Provides ::Hash::Hooked.