class_kit 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2c75a99683cefb096b81e5f55e5a8ac38575e15c7bcdaf38e38aa2f4945a200
4
- data.tar.gz: 0f9d1bffbbdfd43f8552c3d7b8302423f91150549de3bfe1207a7d034e444573
3
+ metadata.gz: 989b0fa8ae54bae48724ae95934a9dd7a8872b345d1f1f4f6bb6d3071791ff21
4
+ data.tar.gz: 13f1992842fc11af845c6e6f2b2a242a204326ac4b8a4fd3645e0c2a01047acf
5
5
  SHA512:
6
- metadata.gz: 9e0f93190d74553720145a8a84256a5219ec0e4df484d507fb8217673030b18c1a17283ec3d8a8f440f401c44948dcb284bf428e3f8a09e1098318b8261e7a11
7
- data.tar.gz: 3e16c3562642437bb97bfe69d01f7d2b4c85fe59d27cbeb8a0df4e869aaba1d2554fe1c23ee6456e28d656053dadabafe2765e71ac2b4e949342799f81d2bcfb
6
+ metadata.gz: b3dd9a041acaacfac965cfe4891d82d968630d05a1dbcf37340472f5f124ceafd5c51d43d3437047d2afdb1a67da5f10d63de691643c970dc3bec9fa3cd6f52f
7
+ data.tar.gz: 31fa61992fea8bed0ef6f5e721ef1a7b3c507ee173afaecb1627bb3763ca83aa6a0245d4ae245fa0a191590ce50e196a4b869ea9a96a12e28645a8f1a94d4aa9
data/lib/class_kit.rb CHANGED
@@ -3,6 +3,7 @@ require_relative 'class_kit/exceptions'
3
3
  require_relative 'class_kit/attribute_helper'
4
4
  require_relative 'class_kit/value_helper'
5
5
  require_relative 'class_kit/helper'
6
+ require_relative 'class_kit/version'
6
7
  require 'hash_kit'
7
8
  require 'json'
8
9
  require 'date'
@@ -5,12 +5,18 @@ module ClassKit
5
5
  @instance ||= ClassKit::AttributeHelper.new
6
6
  end
7
7
 
8
+ def initialize
9
+ @attribute_store = {}
10
+ end
11
+
8
12
  # Get attributes for a given class
9
13
  #
10
14
  # @param klass [ClassKit] a class that has been extended with ClassKit
11
15
  #
12
16
  # @return [Hash]
13
17
  def get_attributes(klass)
18
+ return @attribute_store[klass] if @attribute_store.key?(klass)
19
+
14
20
  attributes = []
15
21
  klass.ancestors.map do |k|
16
22
  hash = k.instance_variable_get(:@class_kit_attributes)
@@ -20,7 +26,10 @@ module ClassKit
20
26
  end
21
27
  end
22
28
  end
23
- attributes.compact
29
+ attributes.compact!
30
+
31
+ @attribute_store[klass] = attributes
32
+ attributes
24
33
  end
25
34
 
26
35
  # Get attribute for a given class and name
@@ -53,6 +53,8 @@ module ClassKit
53
53
  def from_hash(hash:, klass:, use_alias: false)
54
54
  validate_class_kit(klass)
55
55
 
56
+ return hash.map { |i| from_hash(hash: i, klass: klass, use_alias: use_alias) } if hash.is_a?(Array)
57
+
56
58
  @hash_helper.indifferent!(hash)
57
59
  entity = klass.new
58
60
  attributes = @attribute_helper.get_attributes(klass)
@@ -0,0 +1,5 @@
1
+ # Namespace
2
+ module ClassKit
3
+ # :nodoc:
4
+ VERSION = '0.7.0'
5
+ end
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.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sage One
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-07 00:00:00.000000000 Z
11
+ date: 2018-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -42,18 +56,18 @@ dependencies:
42
56
  name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - "~>"
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: '3.0'
61
+ version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - "~>"
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
- version: '3.0'
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: pry
70
+ name: simplecov
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
@@ -67,7 +81,7 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: json
84
+ name: hash_kit
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ">="
@@ -81,7 +95,7 @@ dependencies:
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
- name: hash_kit
98
+ name: json
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="
@@ -111,6 +125,7 @@ files:
111
125
  - lib/class_kit/exceptions/invalid_parse_value_error.rb
112
126
  - lib/class_kit/helper.rb
113
127
  - lib/class_kit/value_helper.rb
128
+ - lib/class_kit/version.rb
114
129
  homepage: https://github.com/sage/class_kit
115
130
  licenses:
116
131
  - MIT