lib/ruby-lokalise-api/utils/attribute_helpers.rb
# Returns the name of the API resource for the given class.
# Most class names correspond to resource names (eg, `Project`, `Team`)
# but some may differ (`ProjectComment` corresponds to `Comment` resource).
# The resource name is in lowercase, with underscores as separators.
# Some resources also have different pluralization rules. For example,
# "CustomTranslationStatus" is "CustomTranslationStatuses" (-es postfix).
# To address that, we try to fetch `DATA_KEY_PLURAL` set for the individual class.
#
# @return [String]
# @param model_class [String]
# @param plural [Boolean] Should the returned value be pluralized?
Returns the name of the API resource for the given class.
Most class names correspond to resource names
but some may differ (`ProjectComment` corresponds to `Comment` resource).
The resource name is in lowercase, with underscores as separators.
Some resources also have different pluralization rules. For example,
"CustomTranslationStatus" is "CustomTranslationStatuses" (-es postfix).
To address that, we try to fetch `DATA_KEY_PLURAL` set for the individual class.
Returns the name of the API resource for the given class . Most class names correspond to resource names but some may differ ( ` ProjectComment ` corresponds to ` Comment ` resource ) . The resource name is in lowercase with underscores as separators . Some resources also have different pluralization rules . For example " CustomTranslationStatus " is " CustomTranslationStatuses " ( - es postfix ) . To address that we try to fetch ` DATA_KEY_PLURAL ` set for the individual class .
def data_key_for(model_class:, plural: false, collection: false)
        data_key_plural = get_key(
          name: 'DATA_KEY_PLURAL',
          model_class: model_class,
          collection: true,
          strict: true
        )
        return data_key_plural if collection && data_key_plural
        data_key = get_key name: 'DATA_KEY', model_class: model_class, collection: collection
        return data_key unless plural
        "#{data_key}s"
      end
def data_key_for ( model_class : , plural : false , collection : false ) data_key_plural = get_key ( name : 'DATA_KEY_PLURAL' , model_class : model_class , collection : true , strict : true ) return data_key_plural if collection && data_key_plural data_key = get_key name : 'DATA_KEY' , model_class : model_class , collection : collection return data_key unless plural "#{data_key}s" end
Returns the name of the API resource for the given class.
Returns the name of the API resource for the given class .
None
String
model_class
plural
None
collection
None