attribute_struct 0.2.20 → 0.2.22
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b824f9b0f1c12f9d33cf496af7d88899dc9634e7
|
4
|
+
data.tar.gz: 1a6e058a77f4ebc0189a8367b56797208519ed1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73056b0aaf9645e3a51db712dd5d4351483760135a26e395fa4170e507bb21c8488f3fdb1eb816a9e1e5a29a925c89a553fd596dacb339f5cef9ab2b7c8bb25d
|
7
|
+
data.tar.gz: 3350700bcd1745bf4ffa03d5f25b840ea7908dd554a50cb147ac2e9d2cf31a401e20e68780974d11ea21027359ac42ae5e2b1c208bc6a811609bc488aa2bd13f
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'attribute_struct
|
1
|
+
require 'attribute_struct'
|
2
2
|
|
3
3
|
class AttributeStruct
|
4
4
|
|
@@ -211,7 +211,7 @@ class AttributeStruct
|
|
211
211
|
#
|
212
212
|
# @api private
|
213
213
|
def convert_key(key)
|
214
|
-
key.kind_of?(Symbol) ? key.to_s : key
|
214
|
+
key.kind_of?(Symbol) || key.kind_of?(String) ? CamelString.new(key.to_s) : key
|
215
215
|
end
|
216
216
|
|
217
217
|
# @param value<Object> The value to convert.
|
@@ -1,7 +1,9 @@
|
|
1
|
-
require 'attribute_struct
|
1
|
+
require 'attribute_struct'
|
2
2
|
|
3
3
|
class AttributeStruct < BasicObject
|
4
4
|
|
5
|
+
autoload :Mash, 'attribute_struct/attribute_hash'
|
6
|
+
|
5
7
|
class << self
|
6
8
|
|
7
9
|
# @return [Truthy, Falsey] global flag for camel keys
|
@@ -214,14 +216,31 @@ class AttributeStruct < BasicObject
|
|
214
216
|
end
|
215
217
|
return endpoint # custom break out
|
216
218
|
else
|
219
|
+
if(args.size > 1)
|
220
|
+
val = args.map do |v|
|
221
|
+
if(v.is_a?(::Hash) && _state(:hash_load_struct))
|
222
|
+
val = _klass_new
|
223
|
+
val._load(v)
|
224
|
+
else
|
225
|
+
v
|
226
|
+
end
|
227
|
+
end
|
228
|
+
else
|
229
|
+
if(args.first.is_a?(::Hash) && _state(:hash_load_struct))
|
230
|
+
val = _klass_new
|
231
|
+
val._load(args.first)
|
232
|
+
else
|
233
|
+
val = args.first
|
234
|
+
end
|
235
|
+
end
|
217
236
|
if(_state(:value_collapse) && !(leaf = @table[sym]).nil?)
|
218
237
|
unless(leaf.is_a?(CollapseArray))
|
219
238
|
leaf = CollapseArray.new.push(leaf)
|
220
239
|
end
|
221
|
-
leaf <<
|
240
|
+
leaf << val
|
222
241
|
@table[sym] = leaf
|
223
242
|
else
|
224
|
-
@table[sym] =
|
243
|
+
@table[sym] = val
|
225
244
|
end
|
226
245
|
end
|
227
246
|
end
|
@@ -301,7 +320,6 @@ class AttributeStruct < BasicObject
|
|
301
320
|
end
|
302
321
|
end
|
303
322
|
hashish.each do |key, value|
|
304
|
-
key = key.dup
|
305
323
|
if(value.is_a?(::Enumerable))
|
306
324
|
flat = value.map do |v|
|
307
325
|
v.is_a?(::Hash) ? _klass.new(v) : v
|
@@ -380,8 +398,8 @@ class AttributeStruct < BasicObject
|
|
380
398
|
# @param args [Object] argument list (:force will force processing)
|
381
399
|
# @return [String, Symbol]
|
382
400
|
def _process_key(key, *args)
|
383
|
-
key = key.to_s
|
384
|
-
if(_camel_keys && _camel_keys_action)
|
401
|
+
key = ::CamelString.new(key.to_s)
|
402
|
+
if(_camel_keys && _camel_keys_action && !key._hump_format_requested?)
|
385
403
|
case _camel_keys_action
|
386
404
|
when :auto_disable
|
387
405
|
key._no_hump
|
@@ -394,10 +412,6 @@ class AttributeStruct < BasicObject
|
|
394
412
|
"#{part[0,1].upcase}#{part[1,part.size]}"
|
395
413
|
end.join.to_sym
|
396
414
|
else
|
397
|
-
if(_camel_keys)
|
398
|
-
# Convert so Hash doesn't make a new one and lose the meta
|
399
|
-
key = ::CamelString.new(key) unless key.is_a?(::CamelString)
|
400
|
-
end
|
401
415
|
key
|
402
416
|
end
|
403
417
|
end
|
@@ -430,6 +444,7 @@ class AttributeStruct < BasicObject
|
|
430
444
|
def _camel_keys_set(v)
|
431
445
|
@_camel_keys_set = v
|
432
446
|
end
|
447
|
+
alias_method :camel_keys_set!, :_camel_keys_set
|
433
448
|
|
434
449
|
# @return [Symbol, NilClass] :auto_disable or :auto_enable
|
435
450
|
def _camel_keys_action
|
@@ -21,9 +21,13 @@ unless(defined?(MonkeyCamels))
|
|
21
21
|
# Create a camel copy based on settings
|
22
22
|
#
|
23
23
|
# @return [String]
|
24
|
-
def camel_initialize_copy(orig)
|
24
|
+
def camel_initialize_copy(orig, hump=nil)
|
25
25
|
new_val = un_camel_initialize_copy(orig)
|
26
|
-
|
26
|
+
if(hump.nil?)
|
27
|
+
orig._camel? ? new_val : new_val._no_hump
|
28
|
+
else
|
29
|
+
new_val._no_hump if hump == false
|
30
|
+
end
|
27
31
|
end
|
28
32
|
|
29
33
|
# Provide string formatted based on hump setting
|
@@ -36,6 +40,11 @@ unless(defined?(MonkeyCamels))
|
|
36
40
|
|
37
41
|
module Humps
|
38
42
|
|
43
|
+
# @return [TrueClass, FalseClass] specific style requested
|
44
|
+
def _hump_format_requested?
|
45
|
+
@__not_camel != nil
|
46
|
+
end
|
47
|
+
|
39
48
|
# @return [TrueClass, FalseClass] camelized
|
40
49
|
def _camel?
|
41
50
|
!@__not_camel
|
@@ -46,12 +55,14 @@ unless(defined?(MonkeyCamels))
|
|
46
55
|
@__not_camel = true
|
47
56
|
self
|
48
57
|
end
|
58
|
+
alias_method :disable_camel!, :_no_hump
|
49
59
|
|
50
60
|
# @return [self] enable camelizing
|
51
61
|
def _hump
|
52
62
|
@__not_camel = false
|
53
63
|
self
|
54
64
|
end
|
65
|
+
alias_method :camel!, :_hump
|
55
66
|
|
56
67
|
end
|
57
68
|
|
data/lib/attribute_struct.rb
CHANGED
@@ -1 +1,7 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
autoload :AttributeStruct, 'attribute_struct/attribute_struct'
|
3
|
+
autoload :MonkeyCamels, 'attribute_struct/monkey_camels'
|
4
|
+
autoload :CamelString, 'attribute_struct/monkey_camels'
|
5
|
+
autoload :IrbCompat, 'attribute_struct/irb_compat'
|
6
|
+
|
7
|
+
require 'attribute_struct/version'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attribute_struct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Attribute structures
|
14
14
|
email: chrisroberts.code@gmail.com
|
@@ -52,3 +52,4 @@ signing_key:
|
|
52
52
|
specification_version: 4
|
53
53
|
summary: Attribute structures
|
54
54
|
test_files: []
|
55
|
+
has_rdoc:
|