case_transform2 0.2 → 1.0.0
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 +5 -5
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/.travis.yml +2 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +3 -8
- data/{LICENSE → LICENSE.txt} +6 -5
- data/README.md +12 -6
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/{case_transform.gemspec → case_transform2.gemspec} +3 -2
- data/lib/case_transform2.rb +111 -2
- data/lib/{case_transform → case_transform2}/hash_ext.rb +4 -1
- data/lib/{case_transform → case_transform2}/string_ext.rb +2 -1
- data/lib/case_transform2/version.rb +5 -0
- metadata +25 -9
- data/lib/case_transform.rb +0 -112
- data/lib/case_transform/version.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2508f1e130309a456cd3c7b57155fde46dd4bfb2da6a04d17763fa4e1b3b5625
|
4
|
+
data.tar.gz: d4ce5240085406f08ee747089147fe18d538eaf09f0a3252334787b74cffdd91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 941332e0e0be855f72d31490ed0dc42a299cfaab150fde878ea6fee3c9c1b9c8145802df65b53cdc974f430bf4771c8ca46684b15cbd9cef9c44a8b16fd399bc
|
7
|
+
data.tar.gz: 2e69588e55a311133b5c5c9742d2293ad29df217d5c6ff93977bf465daac6ba90bf9e74dda339736518509df5e5e3e8c03b62ab6161333c973bd78153980a1a9
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.travis.yml
CHANGED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at saiqulhaq@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
CHANGED
@@ -1,11 +1,6 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
source "https://rubygems.org"
|
4
2
|
|
5
|
-
|
6
|
-
gemspec
|
3
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
gem "guard-rspec"
|
11
|
-
end
|
5
|
+
# Specify your gem's dependencies in case_transform2.gemspec
|
6
|
+
gemspec
|
data/{LICENSE → LICENSE.txt}
RENAMED
@@ -1,6 +1,7 @@
|
|
1
|
-
MIT License
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
3
|
Copyright (c) 2016 L. Preston Sego III
|
4
|
+
Copyright (c) 2018 M. Saiqul Haq
|
4
5
|
|
5
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
7
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -9,13 +10,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
10
|
copies of the Software, and to permit persons to whom the Software is
|
10
11
|
furnished to do so, subject to the following conditions:
|
11
12
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
copies or substantial portions of the Software.
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
14
|
+
all copies or substantial portions of the Software.
|
14
15
|
|
15
16
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
17
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
18
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
19
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
20
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
SOFTWARE.
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
+ [case_transform2](#case_transform2)
|
4
4
|
* [Why](#why)
|
5
5
|
* [Install](#install)
|
6
|
+
* [Warning](#warning)
|
6
7
|
* [Usage](#usage)
|
7
8
|
* [Transforms](#transforms)
|
8
9
|
* [NOTE](#note)
|
@@ -37,22 +38,27 @@ or
|
|
37
38
|
gem install case_transform2
|
38
39
|
```
|
39
40
|
|
41
|
+
## Warning
|
42
|
+
|
43
|
+
if you use 0.x version and want to upgrade to newest version
|
44
|
+
you *must* rename all CaseTransform to be CaseTransform2
|
45
|
+
|
40
46
|
## Usage
|
41
47
|
|
42
48
|
```ruby
|
43
49
|
require 'case_transform2'
|
44
50
|
|
45
51
|
value = "hello_world"
|
46
|
-
|
52
|
+
CaseTransform2.camel_lower(value) # => helloWorld
|
47
53
|
|
48
54
|
value = "hello_world"
|
49
|
-
|
55
|
+
CaseTransform2.camel(value) # => HelloWorld
|
50
56
|
|
51
57
|
value = "hello_world"
|
52
|
-
|
58
|
+
CaseTransform2.dash(value) # => hello-world
|
53
59
|
|
54
60
|
value = "helloWorld"
|
55
|
-
|
61
|
+
CaseTransform2.underscore(value) # => hello_world
|
56
62
|
```
|
57
63
|
|
58
64
|
`value` can be any of Array, Hash, Symbol, or String.
|
@@ -69,6 +75,6 @@ Any other object type will just be returned.
|
|
69
75
|
|
70
76
|
## NOTE
|
71
77
|
|
72
|
-
There is no `
|
78
|
+
There is no `CaseTransform2.unaltered` method like the original gem has
|
73
79
|
|
74
|
-
License
|
80
|
+
License: See LICENSE.txt file
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "case_transform2"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
lib = File.expand_path("lib", __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require "
|
5
|
+
require "case_transform2/version"
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "case_transform2"
|
9
|
-
s.version =
|
9
|
+
s.version = CaseTransform2::VERSION
|
10
10
|
s.license = "MIT"
|
11
11
|
s.authors = ["L. Preston Sego III", "Ben Mills", "Saiqul Haq"]
|
12
12
|
s.email = "saiqulhaq@gmail.com"
|
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
|
25
25
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
26
26
|
|
27
|
+
s.add_development_dependency "bundler", "~> 1.16"
|
27
28
|
s.add_development_dependency "pry", "~> 0.10.4"
|
28
29
|
s.add_development_dependency "rake", "~> 11.2.2"
|
29
30
|
s.add_development_dependency "rspec", "~> 3.7.0"
|
data/lib/case_transform2.rb
CHANGED
@@ -1,2 +1,111 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "case_transform2/hash_ext"
|
4
|
+
require "case_transform2/string_ext"
|
5
|
+
require "case_transform2/version"
|
6
|
+
|
7
|
+
module CaseTransform2
|
8
|
+
class << self
|
9
|
+
# Transforms values to UpperCamelCase or PascalCase.
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# "some_key" => "SomeKey",
|
13
|
+
def camel(value)
|
14
|
+
case value
|
15
|
+
when Array
|
16
|
+
value.map { |item| camel(item) }
|
17
|
+
when Hash
|
18
|
+
hash_ext.deep_transform_keys!(value) { |key| camel(key) }
|
19
|
+
when Symbol
|
20
|
+
camel(value.to_s).to_sym
|
21
|
+
when String
|
22
|
+
camel_cache[value] ||= string_ext.camelize(string_ext.underscore(value))
|
23
|
+
else
|
24
|
+
value
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Transforms values to camelCase.
|
29
|
+
#
|
30
|
+
# @example
|
31
|
+
# "some_key" => "someKey",
|
32
|
+
def camel_lower(value)
|
33
|
+
case value
|
34
|
+
when Array
|
35
|
+
value.map { |item| camel_lower(item) }
|
36
|
+
when Hash
|
37
|
+
hash_ext.deep_transform_keys!(value) { |key| camel_lower(key) }
|
38
|
+
when Symbol
|
39
|
+
camel_lower(value.to_s).to_sym
|
40
|
+
when String
|
41
|
+
camel_lower_cache[value] ||= string_ext.camelize(string_ext.underscore(value), :lower)
|
42
|
+
else
|
43
|
+
value
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Transforms values to dashed-case.
|
48
|
+
#
|
49
|
+
# @example
|
50
|
+
# "some_key" => "some-key",
|
51
|
+
def dash(value)
|
52
|
+
case value
|
53
|
+
when Array
|
54
|
+
value.map { |item| dash(item) }
|
55
|
+
when Hash
|
56
|
+
hash_ext.deep_transform_keys!(value) { |key| dash(key) }
|
57
|
+
when Symbol
|
58
|
+
dash(value.to_s).to_sym
|
59
|
+
when String
|
60
|
+
dash_cache[value] ||= string_ext.dasherize(string_ext.underscore(value))
|
61
|
+
else
|
62
|
+
value
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Transforms values to underscore_case.
|
67
|
+
#
|
68
|
+
# @example
|
69
|
+
# "some-key" => "some_key",
|
70
|
+
def underscore(value)
|
71
|
+
case value
|
72
|
+
when Array
|
73
|
+
value.map { |item| underscore(item) }
|
74
|
+
when Hash
|
75
|
+
hash_ext.deep_transform_keys!(value) { |key| underscore(key) }
|
76
|
+
when Symbol
|
77
|
+
underscore(value.to_s).to_sym
|
78
|
+
when String
|
79
|
+
underscore_cache[value] ||= string_ext.underscore(value)
|
80
|
+
else
|
81
|
+
value
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def string_ext
|
88
|
+
@string_ext ||= CaseTransform2::StringExt.new
|
89
|
+
end
|
90
|
+
|
91
|
+
def hash_ext
|
92
|
+
@hash_ext ||= CaseTransform2::HashExt.new
|
93
|
+
end
|
94
|
+
|
95
|
+
def camel_cache
|
96
|
+
@camel_cache ||= {}
|
97
|
+
end
|
98
|
+
|
99
|
+
def camel_lower_cache
|
100
|
+
@camel_lower_cache ||= {}
|
101
|
+
end
|
102
|
+
|
103
|
+
def dash_cache
|
104
|
+
@dash_cache ||= {}
|
105
|
+
end
|
106
|
+
|
107
|
+
def underscore_cache
|
108
|
+
@underscore_cache ||= {}
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module CaseTransform2
|
4
4
|
# String class extension
|
5
5
|
# Stolen from ActiveSupport::Inflector.camelize
|
6
|
+
# @api private
|
6
7
|
class StringExt
|
7
8
|
def camelize(string, first_letter = :upper)
|
8
9
|
raise ArgumentError, "Argument can not be nil" unless %i[upper lower].include?(first_letter)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: case_transform2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- L. Preston Sego III
|
@@ -10,8 +10,22 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-05
|
13
|
+
date: 2018-07-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bundler
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.16'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.16'
|
15
29
|
- !ruby/object:Gem::Dependency
|
16
30
|
name: pry
|
17
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,18 +94,20 @@ files:
|
|
80
94
|
- ".rspec"
|
81
95
|
- ".rubocop.yml"
|
82
96
|
- ".travis.yml"
|
97
|
+
- CODE_OF_CONDUCT.md
|
83
98
|
- Gemfile
|
84
99
|
- Gemfile.lock
|
85
100
|
- Guardfile
|
86
|
-
- LICENSE
|
101
|
+
- LICENSE.txt
|
87
102
|
- README.md
|
88
103
|
- Rakefile
|
89
|
-
-
|
90
|
-
-
|
91
|
-
-
|
92
|
-
- lib/case_transform/string_ext.rb
|
93
|
-
- lib/case_transform/version.rb
|
104
|
+
- bin/console
|
105
|
+
- bin/setup
|
106
|
+
- case_transform2.gemspec
|
94
107
|
- lib/case_transform2.rb
|
108
|
+
- lib/case_transform2/hash_ext.rb
|
109
|
+
- lib/case_transform2/string_ext.rb
|
110
|
+
- lib/case_transform2/version.rb
|
95
111
|
homepage: https://github.com/saiqulhaq/case_transform
|
96
112
|
licenses:
|
97
113
|
- MIT
|
@@ -113,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
129
|
version: '0'
|
114
130
|
requirements: []
|
115
131
|
rubyforge_project:
|
116
|
-
rubygems_version: 2.
|
132
|
+
rubygems_version: 2.7.3
|
117
133
|
signing_key:
|
118
134
|
specification_version: 4
|
119
135
|
summary: Transforms string letter case to camel, snake, dash and underscore without
|
data/lib/case_transform.rb
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'case_transform/hash_ext'
|
3
|
-
require 'case_transform/string_ext'
|
4
|
-
require 'case_transform/version'
|
5
|
-
|
6
|
-
module CaseTransform
|
7
|
-
class << self
|
8
|
-
def camel_cache
|
9
|
-
@camel_cache ||= {}
|
10
|
-
end
|
11
|
-
|
12
|
-
def camel_lower_cache
|
13
|
-
@camel_lower_cache ||= {}
|
14
|
-
end
|
15
|
-
|
16
|
-
def dash_cache
|
17
|
-
@dash_cache ||= {}
|
18
|
-
end
|
19
|
-
|
20
|
-
def underscore_cache
|
21
|
-
@underscore_cache ||= {}
|
22
|
-
end
|
23
|
-
|
24
|
-
# Transforms values to UpperCamelCase or PascalCase.
|
25
|
-
#
|
26
|
-
# @example:
|
27
|
-
# "some_key" => "SomeKey",
|
28
|
-
def camel(value)
|
29
|
-
case value
|
30
|
-
when Array
|
31
|
-
value.map { |item| camel(item) }
|
32
|
-
when Hash
|
33
|
-
hash_ext.deep_transform_keys!(value) { |key| camel(key) }
|
34
|
-
when Symbol
|
35
|
-
camel(value.to_s).to_sym
|
36
|
-
when String
|
37
|
-
camel_cache[value] ||= string_ext.camelize(string_ext.underscore(value))
|
38
|
-
else
|
39
|
-
value
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# Transforms values to camelCase.
|
44
|
-
#
|
45
|
-
# @example:
|
46
|
-
# "some_key" => "someKey",
|
47
|
-
def camel_lower(value)
|
48
|
-
case value
|
49
|
-
when Array
|
50
|
-
value.map { |item| camel_lower(item) }
|
51
|
-
when Hash
|
52
|
-
hash_ext.deep_transform_keys!(value) { |key| camel_lower(key) }
|
53
|
-
when Symbol
|
54
|
-
camel_lower(value.to_s).to_sym
|
55
|
-
when String
|
56
|
-
camel_lower_cache[value] ||= string_ext.camelize(string_ext.underscore(value), :lower)
|
57
|
-
else
|
58
|
-
value
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
# Transforms values to dashed-case.
|
63
|
-
# This is the default case for the JsonApi adapter.
|
64
|
-
#
|
65
|
-
# @example:
|
66
|
-
# "some_key" => "some-key",
|
67
|
-
def dash(value)
|
68
|
-
case value
|
69
|
-
when Array
|
70
|
-
value.map { |item| dash(item) }
|
71
|
-
when Hash
|
72
|
-
hash_ext.deep_transform_keys!(value) { |key| dash(key) }
|
73
|
-
when Symbol
|
74
|
-
dash(value.to_s).to_sym
|
75
|
-
when String
|
76
|
-
dash_cache[value] ||= string_ext.dasherize(string_ext.underscore(value))
|
77
|
-
else
|
78
|
-
value
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
# Transforms values to underscore_case.
|
83
|
-
# This is the default case for deserialization in the JsonApi adapter.
|
84
|
-
#
|
85
|
-
# @example:
|
86
|
-
# "some-key" => "some_key",
|
87
|
-
def underscore(value)
|
88
|
-
case value
|
89
|
-
when Array
|
90
|
-
value.map { |item| underscore(item) }
|
91
|
-
when Hash
|
92
|
-
hash_ext.deep_transform_keys!(value) { |key| underscore(key) }
|
93
|
-
when Symbol
|
94
|
-
underscore(value.to_s).to_sym
|
95
|
-
when String
|
96
|
-
underscore_cache[value] ||= string_ext.underscore(value)
|
97
|
-
else
|
98
|
-
value
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
private
|
103
|
-
|
104
|
-
def string_ext
|
105
|
-
@string_ext ||= CaseTransform::StringExt.new
|
106
|
-
end
|
107
|
-
|
108
|
-
def hash_ext
|
109
|
-
@hash_ext ||= CaseTransform::HashExt.new
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|