Sha256: aa910a59a591cff987c8e2708f8551f9b5688e0e8119980b45631317a697f88d

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module RubyLokaliseApi
  module Utils
    module Keys
      using RubyLokaliseApi::Utils::Strings

      # Reads DATA_KEY for resources. DATA_KEY specifies the name of the key
      # in the API response that contains the actual data
      def data_key_for(klass:)
        key = if Module.const_defined? "RubyLokaliseApi::Resources::#{klass}::DATA_KEY"
                Module.const_get "RubyLokaliseApi::Resources::#{klass}::DATA_KEY"
              else
                klass
              end

        key.snakecase
      end

      # Reads DATA_KEY for collections. DATA_KEY specifies the name of the key
      # in the API response that contains the actual data
      def collection_key_for(klass:)
        key = if Module.const_defined?("RubyLokaliseApi::Collections::#{klass}::DATA_KEY")
                Module.const_get("RubyLokaliseApi::Collections::#{klass}::DATA_KEY")
              else
                klass
              end

        key.snakecase
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-lokalise-api-9.0.1 lib/ruby_lokalise_api/utils/keys.rb
ruby-lokalise-api-9.0.0 lib/ruby_lokalise_api/utils/keys.rb
ruby-lokalise-api-8.0.1 lib/ruby_lokalise_api/utils/keys.rb
ruby-lokalise-api-8.0.0 lib/ruby_lokalise_api/utils/keys.rb