mirror of
https://github.com/ditkrg/schemable.git
synced 2026-01-22 22:26:41 +00:00
Adds Camelize Keys Method to Definitions
This commit is contained in:
parent
92d9f33d20
commit
e25dfff4ec
@ -95,5 +95,9 @@ module Schemable
|
||||
def model_name
|
||||
self.class.name.gsub('Swagger::Definitions::', '').pluralize.underscore.downcase
|
||||
end
|
||||
|
||||
def camelize_keys(hash)
|
||||
hash.deep_transform_keys { |key| key.to_s.camelize(:lower).to_sym }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -247,5 +247,15 @@ module Schemable
|
||||
# 'users' for the User model
|
||||
# 'citizen_applications' for the CitizenApplication model
|
||||
def model_name: -> String
|
||||
|
||||
# Given a hash, it returns a new hash with all the keys camelized.
|
||||
#
|
||||
# @param hash [Array | Hash] The hash with all the keys camelized.
|
||||
#
|
||||
# @return [Array | Hash] The hash with all the keys camelized.
|
||||
#
|
||||
# @example
|
||||
# { first_name: 'John', last_name: 'Doe' } => { firstName: 'John', lastName: 'Doe' }
|
||||
def camelize_keys: (Hash[Symbol, any]) -> (Hash[Symbol, any] | Array[Hash[Symbol, any]])
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user