alba 1.0.0 → 1.4.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 +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +26 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/dependabot.yml +26 -0
- data/.github/workflows/main.yml +10 -1
- data/.github/workflows/perf.yml +21 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +33 -8
- data/.yardopts +2 -0
- data/CHANGELOG.md +45 -0
- data/Gemfile +12 -6
- data/README.md +259 -24
- data/Rakefile +4 -1
- data/SECURITY.md +12 -0
- data/alba.gemspec +3 -3
- data/benchmark/collection.rb +392 -0
- data/benchmark/single_resource.rb +370 -0
- data/codecov.yml +8 -0
- data/gemfiles/all.gemfile +19 -0
- data/gemfiles/without_active_support.gemfile +17 -0
- data/gemfiles/without_oj.gemfile +17 -0
- data/lib/alba.rb +69 -26
- data/lib/alba/association.rb +14 -22
- data/lib/alba/default_inflector.rb +36 -0
- data/lib/alba/key_transform_factory.rb +33 -0
- data/lib/alba/many.rb +3 -2
- data/lib/alba/one.rb +3 -2
- data/lib/alba/resource.rb +171 -62
- data/lib/alba/typed_attribute.rb +61 -0
- data/lib/alba/version.rb +1 -1
- data/script/perf_check.rb +174 -0
- data/sider.yml +2 -4
- metadata +22 -10
- data/benchmark/local.rb +0 -198
- data/lib/alba/key_transformer.rb +0 -31
data/lib/alba/key_transformer.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
module Alba
|
2
|
-
# Transform keys using `ActiveSupport::Inflector`
|
3
|
-
module KeyTransformer
|
4
|
-
begin
|
5
|
-
require 'active_support/inflector'
|
6
|
-
rescue LoadError
|
7
|
-
raise ::Alba::Error, 'To use transform_keys, please install `ActiveSupport` gem.'
|
8
|
-
end
|
9
|
-
|
10
|
-
module_function
|
11
|
-
|
12
|
-
# Transform key as given transform_type
|
13
|
-
#
|
14
|
-
# @params key [String] key to be transformed
|
15
|
-
# @params transform_type [Symbol] transform type
|
16
|
-
# @return [String] transformed key
|
17
|
-
# @raise [Alba::Error] when transform_type is not supported
|
18
|
-
def transform(key, transform_type)
|
19
|
-
case transform_type
|
20
|
-
when :camel
|
21
|
-
ActiveSupport::Inflector.camelize(key)
|
22
|
-
when :lower_camel
|
23
|
-
ActiveSupport::Inflector.camelize(key, false)
|
24
|
-
when :dash
|
25
|
-
ActiveSupport::Inflector.dasherize(key)
|
26
|
-
else
|
27
|
-
raise ::Alba::Error, "Unknown transform_type: #{transform_type}. Supported transform_type are :camel, :lower_camel and :dash."
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|