skn_utils 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -17
- data/lib/skn_utils/attribute_helpers.rb +1 -1
- data/lib/skn_utils/version.rb +1 -1
- data/skn_utils.gemspec +7 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e225b9bb4186a871f69170536c5392adba40af7
|
4
|
+
data.tar.gz: fcb0aecf0195a93d4f599bc3c79786f04a795e69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 647012d02ff9abf3d91270451d878d603eec0143fbc257c0874c1b3642b72023960c374d592bfb5d3ec98d443c6b39c92de3815b9853187b31f650c08021e465
|
7
|
+
data.tar.gz: 580f585505418a7441b32312bee7862401aa103e3d905b39392da3345421931dd507378356d8fe659c17890e6cd5c4a9967a61c736cdf603634128cae57d8b35
|
data/README.md
CHANGED
@@ -70,8 +70,8 @@ The intent of this component is to be a container of data results, with easy acc
|
|
70
70
|
|
71
71
|
The combination of this NestedResultBase(dot notation class) and AttributeHelpers(hash notation module), produces this effect given the same params hash:
|
72
72
|
|
73
|
-
|
74
|
-
----------------------------------------------------
|
73
|
+
SknUtils::ResultBean.new(params) Basic dot notation: effect of :depth
|
74
|
+
---------------------------------------------------- -----------------------------------------------------------------
|
75
75
|
|
76
76
|
(DOES NOT FOLLOW Values) :depth => :single
|
77
77
|
```ruby
|
@@ -88,8 +88,8 @@ The combination of this NestedResultBase(dot notation class) and AttributeHelper
|
|
88
88
|
(Follow VALUES that are Hashes only.) :depth => :multi
|
89
89
|
```ruby
|
90
90
|
* params = {one: 1, drb.one = 1
|
91
|
-
two: { one: 1, drb.two
|
92
|
-
two: "two"
|
91
|
+
two: { one: 1, drb.two = <SknUtils::ResultBean>
|
92
|
+
two: "two" drb.two.two = 'two'
|
93
93
|
},
|
94
94
|
three: [ {one: 'one', two: 2}, drb.three = [{one: 'one', two: 2},{three: 'three', four: 4}]
|
95
95
|
{three: 'three', four: 4} drb.three[1] = {three: 'three', four: 4}
|
@@ -100,20 +100,20 @@ The combination of this NestedResultBase(dot notation class) and AttributeHelper
|
|
100
100
|
(Follow VALUES that are Hashes and/or Arrays of Hashes) :depth => :multi_with_arrays
|
101
101
|
```ruby
|
102
102
|
* params = {one: 1, drb.one = 1
|
103
|
-
two: { one: 1, drb.two
|
103
|
+
two: { one: 1, drb.two = <SknUtils::ResultBean>
|
104
104
|
two: "two" drb.two.two = 'two'
|
105
105
|
},
|
106
|
-
three: [ {one: 'one', two: 2}, drb.three
|
107
|
-
|
108
|
-
]
|
106
|
+
three: [ {one: 'one', two: 2}, drb.three = [<SknUtils::ResultBean>,<SknUtils::ResultBean>]
|
107
|
+
{three: 'three', four: 4} drb.three[1] = <SknUtils::ResultBean>
|
108
|
+
] drb.three[1].four = 4
|
109
109
|
}
|
110
110
|
|
111
111
|
```
|
112
|
-
# Usage
|
112
|
+
# Usage:
|
113
113
|
|
114
114
|
(DOES NOT FOLLOW Values)
|
115
115
|
```ruby
|
116
|
-
class SmallPackage < NestedResultBase
|
116
|
+
class SmallPackage < SknUtils::NestedResultBase
|
117
117
|
def initialize(params={})
|
118
118
|
super( params.merge({depth: :single}) ) # override default of :multi level
|
119
119
|
end
|
@@ -122,13 +122,13 @@ The combination of this NestedResultBase(dot notation class) and AttributeHelper
|
|
122
122
|
|
123
123
|
(Follow VALUES that are Hashes only.)
|
124
124
|
```ruby
|
125
|
-
class ResultBean < NestedResultBase
|
125
|
+
class ResultBean < SknUtils::NestedResultBase
|
126
126
|
# defaults to :multi level
|
127
127
|
end
|
128
128
|
|
129
129
|
-- or --
|
130
130
|
|
131
|
-
class ResultBean < NestedResultBase
|
131
|
+
class ResultBean < SknUtils::NestedResultBase
|
132
132
|
def initialize(params={})
|
133
133
|
# your other init stuff here
|
134
134
|
super(params) # default taken
|
@@ -137,7 +137,7 @@ The combination of this NestedResultBase(dot notation class) and AttributeHelper
|
|
137
137
|
|
138
138
|
-- or --
|
139
139
|
|
140
|
-
class ResultBean < NestedResultBase
|
140
|
+
class ResultBean < SknUtils::NestedResultBase
|
141
141
|
def initialize(params={})
|
142
142
|
# your other init stuff here
|
143
143
|
super( params.merge({depth: :multi}) ) # Specified
|
@@ -145,7 +145,7 @@ The combination of this NestedResultBase(dot notation class) and AttributeHelper
|
|
145
145
|
end
|
146
146
|
|
147
147
|
** - or -- enable serialization and default to multi
|
148
|
-
class GenericBean < NestedResultBase
|
148
|
+
class GenericBean < SknUtils::NestedResultBase
|
149
149
|
def initialize(params={})
|
150
150
|
super( params.merge({enable_serialization: true}) ) # Specified with Serialization Enabled
|
151
151
|
end
|
@@ -154,7 +154,7 @@ The combination of this NestedResultBase(dot notation class) and AttributeHelper
|
|
154
154
|
|
155
155
|
(Follow VALUES that are Hashes and/or Arrays of Hashes, and enable Serializers)
|
156
156
|
```ruby
|
157
|
-
class PageControl < NestedResultBase
|
157
|
+
class PageControl < SknUtils::NestedResultBase
|
158
158
|
def initialize(params={})
|
159
159
|
super( params.merge({depth: :multi_with_arrays, enable_serialization: true}) ) # override defaults
|
160
160
|
end
|
@@ -163,7 +163,7 @@ The combination of this NestedResultBase(dot notation class) and AttributeHelper
|
|
163
163
|
|
164
164
|
|
165
165
|
NOTE: Cannot be Marshalled/Serialized unless input params.merge({enable_serialization: true}) -- default is false
|
166
|
-
Use GenericBean or PageControls if serialization is needed,
|
166
|
+
Use GenericBean or PageControls if serialization is needed, they initialize with this value true.
|
167
167
|
|
168
168
|
## Installation
|
169
169
|
----------------
|
@@ -183,7 +183,7 @@ Or install it yourself as:
|
|
183
183
|
|
184
184
|
$ gem install skn_utils
|
185
185
|
|
186
|
-
## Build
|
186
|
+
## Build
|
187
187
|
|
188
188
|
1. $ git clone git@github.com:skoona/skn_utils.git
|
189
189
|
2. $ cd skn_utils
|
@@ -133,7 +133,7 @@ module SknUtils
|
|
133
133
|
singleton_class.send(:attr_accessor, method.to_s[0..-2]) unless serial_required?
|
134
134
|
if multi_with_arrays_required?
|
135
135
|
instance_variable_set("@#{method.to_s[0..-2]}",
|
136
|
-
(args.
|
136
|
+
(args.first.map {|nobj| nobj.kind_of?(Hash) ? self.class.new(nobj) : nobj })
|
137
137
|
)
|
138
138
|
else
|
139
139
|
instance_variable_set "@#{method.to_s[0..-2]}", *args
|
data/lib/skn_utils/version.rb
CHANGED
data/skn_utils.gemspec
CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.summary = <<EOF
|
12
12
|
Ruby convenience utilities, the first being a ResultBean.
|
13
13
|
|
14
|
+
|
14
15
|
ResultBean is a PORO (Plain Old Ruby Object) which inherits from NestedResultBean class (inlcuded). This class
|
15
16
|
is intantiated via a hash at Ruby/Rails Runtime, allows access to vars via dot or hash notation,
|
16
17
|
and is serializable via to_xml, to_hash, and to_json.
|
@@ -18,16 +19,21 @@ EOF
|
|
18
19
|
|
19
20
|
spec.description = <<EOF
|
20
21
|
Creates an PORO Object with instance variables and associated getters and setters for each input key, during runtime.
|
22
|
+
|
21
23
|
|
22
24
|
If a key's value is also a hash, it too can optionally become an Object.
|
25
|
+
|
23
26
|
|
24
27
|
If a key's value is a Array of Hashes, each element of the Array can optionally become an Object.
|
28
|
+
|
25
29
|
|
26
30
|
This nesting action is controlled by the value of the options key ':depth'. Options key :depth defaults
|
27
31
|
to :multi, and has options of :single, :multi, or :multi_with_arrays
|
32
|
+
|
28
33
|
|
29
34
|
The ability of the resulting Object to be Marshalled(dump/load) can be preserved by merging configuration options
|
30
|
-
into the input params key ':enable_serialization' set to true. It defaults to false for speed purposes
|
35
|
+
into the input params key ':enable_serialization' set to true. It defaults to false for speed purposes.
|
36
|
+
|
31
37
|
|
32
38
|
Review the RSpec tests, and or review the README for more details.
|
33
39
|
EOF
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skn_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Scott Jr
|
@@ -81,14 +81,14 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: "Creates an PORO Object with instance variables and associated getters
|
84
|
-
and setters for each input key, during runtime.\n \nIf a key's value is also a
|
85
|
-
it too can optionally become an Object.\n \nIf a key's value is a Array
|
86
|
-
each element of the Array can optionally become an Object.\n \nThis
|
87
|
-
is controlled by the value of the options key ':depth'. Options
|
88
|
-
\nto :multi, and has options of :single, :multi, or :multi_with_arrays\n
|
89
|
-
ability of the resulting Object to be Marshalled(dump/load) can be preserved
|
90
|
-
merging configuration options\ninto the input params key ':enable_serialization'
|
91
|
-
set to true. It defaults to false for speed purposes\n\nReview the RSpec tests,
|
84
|
+
and setters for each input key, during runtime.\n\n \nIf a key's value is also a
|
85
|
+
hash, it too can optionally become an Object.\n\n \nIf a key's value is a Array
|
86
|
+
of Hashes, each element of the Array can optionally become an Object.\n\n \nThis
|
87
|
+
nesting action is controlled by the value of the options key ':depth'. Options
|
88
|
+
key :depth defaults \nto :multi, and has options of :single, :multi, or :multi_with_arrays\n\n
|
89
|
+
\ \nThe ability of the resulting Object to be Marshalled(dump/load) can be preserved
|
90
|
+
by merging configuration options\ninto the input params key ':enable_serialization'
|
91
|
+
set to true. It defaults to false for speed purposes.\n\n\nReview the RSpec tests,
|
92
92
|
and or review the README for more details.\n"
|
93
93
|
email: skoona@gmail.com
|
94
94
|
executables: []
|
@@ -142,7 +142,7 @@ rubyforge_project:
|
|
142
142
|
rubygems_version: 2.4.3
|
143
143
|
signing_key:
|
144
144
|
specification_version: 4
|
145
|
-
summary: Ruby convenience utilities, the first being a ResultBean.
|
145
|
+
summary: Ruby convenience utilities, the first being a ResultBean. ResultBean is
|
146
146
|
a PORO (Plain Old Ruby Object) which inherits from NestedResultBean class (inlcuded).
|
147
147
|
This class is intantiated via a hash at Ruby/Rails Runtime, allows access to vars
|
148
148
|
via dot or hash notation, and is serializable via to_xml, to_hash, and to_json.
|