active_object 5.8.11 → 5.9.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: 4048bbff49b6a24c4e9ab029efc0241bb0add2dd5fe584240ab0f07c104ddd94
4
- data.tar.gz: e9151c19ef67880601f31a3d8dc412c1a7581501a98ec839986dd6ec6862792c
3
+ metadata.gz: 881c56690618f36c3f9a10fe57d8effb72a0d3674c37e59902bb81a71f9b4a17
4
+ data.tar.gz: 8a93ffd7957d9b8cf7d49e30a34bed2273e5c9206e2eb79b0120df940aa16f5d
5
5
  SHA512:
6
- metadata.gz: fa7a4df71f2e05bea04c77885880944449abea2add7ac9dee549e8de327c3cb57711138a29beee3b1b09e4e246fc0205fe0d28b7f9c3f808c19afe3e3a6c1a73
7
- data.tar.gz: 9152d040a4ae3ce9124940cc35fe4c682c3353c551c679a5e03992cc3036a74d533a9e7c45f1b079c50c0b509a5d41d45dd30de5abd8ac3d5e7766af8b524f66
6
+ metadata.gz: 16450952ceb4a3514a5b2c3adfe215aec0c0460ef06c93e73689d9109134af035418c1bcc327698ec7c3909af849e82adeb97cd6cc40de4094cacd9d6ff54ec6
7
+ data.tar.gz: 57644c5ec814a62ce95d731f8fdd4ca6fb21d241ea4a3dd273bff0b7afb48a4bc57617dd963ff526867bb4e07a8b8c112f3f487e1632763ed996889d07b9d717
data/.irbrc CHANGED
@@ -5,8 +5,8 @@ begin
5
5
  require 'awesome_print'
6
6
 
7
7
  AwesomePrint.irb!
8
- rescue LoadError => err
9
- warn "Couldn't load awesome_print: #{err}"
8
+ rescue LoadError => e
9
+ warn "Couldn't load awesome_print: #{e}"
10
10
  end
11
11
 
12
12
  # IRB
data/.rubocop.yml CHANGED
@@ -1,7 +1,8 @@
1
+ require: rubocop-performance
1
2
  AllCops:
2
3
  DisplayCopNames: true
3
4
  DisplayStyleGuide: true
4
- TargetRubyVersion: 2.5
5
+ TargetRubyVersion: 2.6
5
6
  Exclude:
6
7
  - 'spec/**/**/*'
7
8
  Performance/RegexpMatch:
data/README.md CHANGED
@@ -172,7 +172,7 @@ end
172
172
  ```
173
173
 
174
174
  **Fulfill:**
175
- `Fulfill` returns an array filled to given size.
175
+ `fulfill` returns an array filled to given size.
176
176
 
177
177
  ```ruby
178
178
  ['1', '2'].fulfill('x', 4) #=> ['1', '2', 'x', 'x']
@@ -818,6 +818,13 @@ h.slice!(:a, :b) #=> { c: 3, d: 4 }
818
818
  { 'firstName' => 'foo', 'last Name' => 'test' }.symbolize_and_underscore_keys #=> { first_name: 'foo', last_name: 'test' }
819
819
  ```
820
820
 
821
+ **To Object:**
822
+ `to_o` converts an object to have an object like API.
823
+
824
+ ```ruby
825
+ { foo: { bar: true } }.to_o.foo.bar #=> true
826
+ ```
827
+
821
828
  **Transform Keys:**
822
829
  `transform_keys` and `transform_keys!` returns a new hash with all keys converted using the block operation.
823
830
 
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'reek'
28
28
  spec.add_development_dependency 'rspec'
29
29
  spec.add_development_dependency 'rubocop'
30
+ spec.add_development_dependency 'rubocop-performance'
30
31
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'json'
4
+
3
5
  module ActiveObject
4
6
  module Hash
5
7
 
@@ -103,7 +105,7 @@ module ActiveObject
103
105
  end
104
106
 
105
107
  def extract!(*keys)
106
- keys.each_with_object({}) { |key, hash| hash[key] = delete(key) if has_key?(key) }
108
+ keys.each_with_object({}) { |key, hash| hash[key] = delete(key) if key?(key) }
107
109
  end
108
110
 
109
111
  def hmap(&block)
@@ -267,6 +269,10 @@ module ActiveObject
267
269
  end
268
270
  end
269
271
 
272
+ def to_o
273
+ JSON.parse(to_json, object_class: OpenStruct)
274
+ end
275
+
270
276
  def transform_keys(&block)
271
277
  dup.transform_keys!(&block)
272
278
  end
@@ -136,7 +136,6 @@ module ActiveObject
136
136
  def try_call(*keys)
137
137
  return unless respond_to?(:call)
138
138
 
139
-
140
139
  keys.blank? ? call : call(*keys)
141
140
  end
142
141
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveObject
4
- VERSION ||= '5.8.11'
4
+ VERSION ||= '5.9.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.8.11
4
+ version: 5.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-01 00:00:00.000000000 Z
11
+ date: 2019-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-performance
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  description: Class extensions of commonly used ruby object helpers.
112
126
  email:
113
127
  - j.gomez@drexed.com