attribute_struct 0.2.10 → 0.2.12

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9b868b2158e6d4180a0284e6570aae190f912dd
4
- data.tar.gz: fea21780da1c0b5aec42317079e94201089ce9a6
3
+ metadata.gz: 4678195877f88a043df9e50bb70bd2b15d6e0de6
4
+ data.tar.gz: 67a4f4870ed31aeabb2e43602c8d996bc2f550ee
5
5
  SHA512:
6
- metadata.gz: d808083f54a73f7d445fe5c2e87433930b18907267ed3bd917679783a1afc82746622b7dc123a21cd9db4b158920a4b88ebf0fd4ea5b53162c327a3752e39c25
7
- data.tar.gz: c0e1f1ef8ffdd5bf32de73ab95d13680829b751470d1c6d1f2d4d7069a2d1eb48753942435e57afd2159533fe972cab0f6e0c1193e0650023238bc0f86092f2a
6
+ metadata.gz: 5d0d0c9f6dd9fb55e757fb2a91988cf7d58ded85d393e75f03261d27f4df0fe9692b1d64385e6cc186079a8e3a7cbb4be494101bd4b6cbf03689d4be17aace36
7
+ data.tar.gz: 27a40c5108a547180fcbb91f2f78db07adf405e42b6ed9a3a3b12a3c533ff594ba52d92f10d84f6d1b689e05586b7cd4d4fe70a545864de136dbdae54125fb91
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v0.2.12
2
+ * Implementation updates to monkey camels helper
3
+ * Provide bang style helper methods for all helpers
4
+
1
5
  ## v0.2.10
2
6
  * Add support for multi parameter set
3
7
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ## AttributeStruct
1
+ # AttributeStruct
2
2
 
3
3
  This is a helper library that essentially builds hashes. It
4
4
  wraps hash building with a nice DSL to make it slightly cleaner,
@@ -8,7 +8,7 @@ more robust, and provide extra features.
8
8
 
9
9
  * [![Build Status](https://api.travis-ci.org/chrisroberts/attribute_struct.png)](https://travis-ci.org/chrisroberts/attribute_struct)
10
10
 
11
- ### Usage
11
+ ## Usage
12
12
 
13
13
  ```ruby
14
14
  require 'attribute_struct'
@@ -51,7 +51,7 @@ which gives:
51
51
  "client"=>{"general"=>{"enabled"=>false}}}}
52
52
  ```
53
53
 
54
- ### IRB
54
+ ## IRB
55
55
 
56
56
  IRB expects some things to be around like `#inspect` and `#to_s`. Before
57
57
  using `AttributeStruct` in IRB, enable compat mode:
@@ -46,6 +46,7 @@ class AttributeStruct < BasicObject
46
46
 
47
47
  end
48
48
 
49
+ # Specialized array for collapsing values
49
50
  class CollapseArray < ::Array; end
50
51
 
51
52
  # @return [Truthy, Falsey] current camelizing setting
@@ -76,6 +77,7 @@ class AttributeStruct < BasicObject
76
77
  def _build(&block)
77
78
  self.instance_exec(&block)
78
79
  end
80
+ alias_method :build!, :_build
79
81
 
80
82
  # Set state into current context
81
83
  #
@@ -84,6 +86,7 @@ class AttributeStruct < BasicObject
84
86
  def _set_state(args={})
85
87
  _arg_state.merge!(args)
86
88
  end
89
+ alias_method :set_state!, :_set_state
87
90
 
88
91
  # Value of requested state
89
92
  #
@@ -99,6 +102,7 @@ class AttributeStruct < BasicObject
99
102
  end
100
103
  end
101
104
  end
105
+ alias_method :state!, :_state
102
106
 
103
107
  # Enable/disable camel keys
104
108
  #
@@ -238,11 +242,13 @@ class AttributeStruct < BasicObject
238
242
  def _keys
239
243
  _data.keys
240
244
  end
245
+ alias_method :keys!, :_keys
241
246
 
242
247
  # @return [AttributeStruct::AttributeHash, Mash] underlying struct data
243
248
  def _data
244
249
  @table
245
250
  end
251
+ alias_method :data!, :_data
246
252
 
247
253
  # Delete entry from struct
248
254
  #
@@ -302,6 +308,7 @@ class AttributeStruct < BasicObject
302
308
  end
303
309
  self
304
310
  end
311
+ alias_method :load!, :_load
305
312
 
306
313
  # Perform deep merge
307
314
  #
@@ -426,6 +433,7 @@ class AttributeStruct < BasicObject
426
433
  @_parent = obj if obj
427
434
  @_parent
428
435
  end
436
+ alias_method :parent!, :_parent
429
437
 
430
438
  # @return [AttributeStruct, NilClass] root of the struct or nil if self is root
431
439
  def _root
@@ -435,6 +443,7 @@ class AttributeStruct < BasicObject
435
443
  end
436
444
  r
437
445
  end
446
+ alias_method :root!, :_root
438
447
 
439
448
  # Create an Array and evaluate discovered AttributeStructs
440
449
  #
@@ -1,70 +1,74 @@
1
1
  require 'attribute_struct'
2
2
 
3
- module MonkeyCamels
3
+ unless(defined?(MonkeyCamels))
4
4
 
5
- class << self
6
- def included(klass)
7
- klass.class_eval do
5
+ module MonkeyCamels
8
6
 
9
- include Humps
7
+ class << self
8
+ def included(klass)
9
+ klass.class_eval do
10
10
 
11
- alias_method :un_camel_to_s, :to_s
12
- alias_method :to_s, :camel_to_s
13
- alias_method :un_camel_initialize_copy, :initialize_copy
14
- alias_method :initialize_copy, :camel_initialize_copy
11
+ include Humps
12
+
13
+ alias_method :un_camel_to_s, :to_s
14
+ alias_method :to_s, :camel_to_s
15
+ alias_method :un_camel_initialize_copy, :initialize_copy
16
+ alias_method :initialize_copy, :camel_initialize_copy
17
+ end
15
18
  end
16
19
  end
17
- end
18
20
 
19
- # Create a camel copy based on settings
20
- #
21
- # @return [String]
22
- def camel_initialize_copy(orig)
23
- new_val = un_camel_initialize_copy(orig)
24
- orig._camel? ? new_val : new_val._no_hump
25
- end
21
+ # Create a camel copy based on settings
22
+ #
23
+ # @return [String]
24
+ def camel_initialize_copy(orig)
25
+ new_val = un_camel_initialize_copy(orig)
26
+ orig._camel? ? new_val : new_val._no_hump
27
+ end
26
28
 
27
- # Provide string formatted based on hump setting
28
- #
29
- # @return [String]
30
- def camel_to_s
31
- val = un_camel_to_s
32
- _camel? ? val : val._no_hump
33
- end
29
+ # Provide string formatted based on hump setting
30
+ #
31
+ # @return [String]
32
+ def camel_to_s
33
+ val = un_camel_to_s
34
+ _camel? ? val : val._no_hump
35
+ end
34
36
 
35
- module Humps
37
+ module Humps
36
38
 
37
- # @return [TrueClass, FalseClass] camelized
38
- def _camel?
39
- !@__not_camel
40
- end
39
+ # @return [TrueClass, FalseClass] camelized
40
+ def _camel?
41
+ !@__not_camel
42
+ end
41
43
 
42
- # @return [self] disable camelizing
43
- def _no_hump
44
- @__not_camel = true
45
- self
46
- end
44
+ # @return [self] disable camelizing
45
+ def _no_hump
46
+ @__not_camel = true
47
+ self
48
+ end
49
+
50
+ # @return [self] enable camelizing
51
+ def _hump
52
+ @__not_camel = false
53
+ self
54
+ end
47
55
 
48
- # @return [self] enable camelizing
49
- def _hump
50
- @__not_camel = false
51
- self
52
56
  end
53
57
 
54
58
  end
55
59
 
56
- end
57
-
58
- # Force some monkeys around
59
- String.send(:include, MonkeyCamels)
60
- Symbol.send(:include, MonkeyCamels)
60
+ # Force some monkeys around
61
+ String.send(:include, MonkeyCamels)
62
+ Symbol.send(:include, MonkeyCamels)
61
63
 
62
- # Specialized String type
63
- class CamelString < String
64
- def initialize(val=nil)
65
- super
66
- if(val.respond_to?(:_camel?))
67
- _no_hump unless val._camel?
64
+ # Specialized String type
65
+ class CamelString < String
66
+ def initialize(val=nil)
67
+ super
68
+ if(val.respond_to?(:_camel?))
69
+ _no_hump unless val._camel?
70
+ end
68
71
  end
69
72
  end
73
+
70
74
  end
@@ -2,5 +2,5 @@ require 'attribute_struct/attribute_struct'
2
2
 
3
3
  class AttributeStruct
4
4
  # Current library version
5
- VERSION = ::Gem::Version.new('0.2.10')
5
+ VERSION = ::Gem::Version.new('0.2.12')
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attribute_struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Roberts