class_kit 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/class_kit/helper.rb +9 -4
- data/lib/class_kit.rb +1 -1
- metadata +2 -17
- data/lib/class_kit/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe1a16b05bdf0a91dd502c6d515510ccf445b614
|
4
|
+
data.tar.gz: b0fee353af3fd8919136e0f37b9408b2ecabb736
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6ccbe25890a6b58f1838ee558ddfe93f8a5bb9c3aa8a387a25294518d8fbbdc5e44fe7bb25858d249fedac739a51cf7008e52b876c5cff3c8c2e671791f7f04
|
7
|
+
data.tar.gz: a6dcd8ae3560b67709da763c8e71f74af6672aa2ae0d1b72890d32a147104b3ee1093d57ac40a58bce59b2326871547ede72e3abd6bbe4d951b6241d0195b882
|
data/lib/class_kit/helper.rb
CHANGED
@@ -3,7 +3,6 @@ module ClassKit
|
|
3
3
|
|
4
4
|
def initialize
|
5
5
|
@hash_helper = HashKit::Helper.new
|
6
|
-
@json_helper = JsonKit::Helper.new
|
7
6
|
@attribute_helper = ClassKit::AttributeHelper.new
|
8
7
|
@value_helper = ClassKit::ValueHelper.new
|
9
8
|
end
|
@@ -17,16 +16,18 @@ module ClassKit
|
|
17
16
|
"Class: #{klass} does not implement ClassKit.")
|
18
17
|
end
|
19
18
|
|
19
|
+
#This method is called to convert a ClassKit object into a Hash.
|
20
20
|
def to_hash(object)
|
21
21
|
validate_class_kit(object.class)
|
22
22
|
|
23
23
|
@hash_helper.to_hash(object)
|
24
24
|
end
|
25
25
|
|
26
|
+
#This method is called to convert a Hash into a ClassKit object.
|
26
27
|
def from_hash(hash:, klass:)
|
27
28
|
validate_class_kit(klass)
|
28
29
|
|
29
|
-
|
30
|
+
@hash_helper.indifferent!(hash)
|
30
31
|
entity = klass.new
|
31
32
|
attributes = @attribute_helper.get_attributes(klass)
|
32
33
|
attributes.each do |attribute|
|
@@ -60,12 +61,16 @@ module ClassKit
|
|
60
61
|
entity
|
61
62
|
end
|
62
63
|
|
64
|
+
#This method is called to convert a ClassKit object into JSON.
|
63
65
|
def to_json(object)
|
64
|
-
@
|
66
|
+
hash = @hash_helper.to_hash(object)
|
67
|
+
JSON.dump(hash)
|
65
68
|
end
|
66
69
|
|
70
|
+
#This method is called to convert JSON into a ClassKit object.
|
67
71
|
def from_json(json:, klass:)
|
68
|
-
|
72
|
+
hash = JSON.load(json)
|
73
|
+
from_hash(hash: hash, klass: klass)
|
69
74
|
end
|
70
75
|
end
|
71
76
|
end
|
data/lib/class_kit.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require_relative 'class_kit/version'
|
2
1
|
require_relative 'class_kit/class_methods'
|
3
2
|
require_relative 'class_kit/exceptions'
|
4
3
|
require_relative 'class_kit/attribute_helper'
|
@@ -8,4 +7,5 @@ require 'hash_kit'
|
|
8
7
|
require 'json'
|
9
8
|
require 'date'
|
10
9
|
require 'bigdecimal'
|
10
|
+
require 'time'
|
11
11
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: class_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sage One
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,20 +94,6 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: json_kit
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :runtime
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
97
|
description: Toolkit for working with classes
|
112
98
|
email:
|
113
99
|
- vaughan.britton@sage.com
|
@@ -125,7 +111,6 @@ files:
|
|
125
111
|
- lib/class_kit/exceptions/invalid_parse_value_error.rb
|
126
112
|
- lib/class_kit/helper.rb
|
127
113
|
- lib/class_kit/value_helper.rb
|
128
|
-
- lib/class_kit/version.rb
|
129
114
|
homepage: https://github.com/sage/class_kit
|
130
115
|
licenses:
|
131
116
|
- MIT
|
data/lib/class_kit/version.rb
DELETED