msmg_public 0.1.1 → 0.1.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.
- checksums.yaml +4 -4
- data/msmg_public.gemspec +1 -1
- data/readme.md +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3286b4a7df45f886b05e6df2a702698299d60108
|
4
|
+
data.tar.gz: bcf230f6b445835a5083fd0335955a2af023742d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f473de15cae665af952d977708b6249408f3daa906848c657ad58289e370e191c784073dc2042f23957eecb3af9476f9dec624e1be3cda5d507b407401980da
|
7
|
+
data.tar.gz: 8f6fce2245e2b4b4db0b866b09c456e58d598f6aa397b6530aed3e9fe4fe8119c2c08e760be5e93c239d40b062be8f45045c8efc99648f1476f7610d5edd74b8
|
data/msmg_public.gemspec
CHANGED
@@ -9,7 +9,7 @@ $LOAD_PATH.merge! [File.expand_path('../lib', __FILE__)]
|
|
9
9
|
Gem::Specification.new do |spec|
|
10
10
|
raise 'RubyGems 2.0 or newer is required.' unless spec.respond_to?(:metadata)
|
11
11
|
spec.name = 'msmg_public'
|
12
|
-
spec.version = '0.1.
|
12
|
+
spec.version = '0.1.2'
|
13
13
|
spec.authors = ['Andrew Smith']
|
14
14
|
spec.email = ['andrew.smith at moneysupermarket.com']
|
15
15
|
|
data/readme.md
CHANGED
@@ -8,6 +8,7 @@ Add a to_hash method to any class that will produce a hash from all instance var
|
|
8
8
|
By default the keys produced are symbols but when called with parameters it will use the parameter form passed for the keys (which can be mixed symbols and strings).
|
9
9
|
In order to make an alternate default of to_hash with a specific set of attributes one may consider implementing to_hash can calling a super method to pass the params i.e.
|
10
10
|
|
11
|
+
```
|
11
12
|
class Foo
|
12
13
|
include ToHash
|
13
14
|
|
@@ -26,6 +27,7 @@ In order to make an alternate default of to_hash with a specific set of attribut
|
|
26
27
|
:foo => 1,
|
27
28
|
'bar' => 2
|
28
29
|
}
|
30
|
+
```
|
29
31
|
|
30
32
|
## ComparableByAttr
|
31
33
|
|
@@ -34,6 +36,7 @@ Adds a default behaviour for <=> based upon instance variables within the class
|
|
34
36
|
Instance variables by default are enumerated, sorted and stored in an array and the arrays are compared with their own l to r behaviour.
|
35
37
|
One may override the instance variables used in the comparison and the order by specifying an attr_compare override in the class definition.
|
36
38
|
|
39
|
+
```
|
37
40
|
# instances will be comparable by [@a, @b, @c]
|
38
41
|
class Bar
|
39
42
|
include ComparableByAttr
|
@@ -56,6 +59,7 @@ One may override the instance variables used in the comparison and the order by
|
|
56
59
|
@c = c
|
57
60
|
end
|
58
61
|
end
|
62
|
+
```
|
59
63
|
|
60
64
|
## dig
|
61
65
|
|
@@ -69,6 +73,7 @@ Documentation from Ruby 2.3.0 states..
|
|
69
73
|
|
70
74
|
Extracts the nested value specified by the sequence of idx objects by calling dig at each step, returning nil if any intermediate step is nil.
|
71
75
|
|
76
|
+
```
|
72
77
|
h = { foo: {bar: {baz: 1}}}
|
73
78
|
|
74
79
|
h.dig(:foo, :bar, :baz) #=> 1
|
@@ -76,3 +81,4 @@ Extracts the nested value specified by the sequence of idx objects by calling di
|
|
76
81
|
|
77
82
|
g = { foo: [10, 11, 12] }
|
78
83
|
g.dig(:foo, 1) #=> 11
|
84
|
+
```
|