Sha256: 1b7ac90c1e373542950449e7892f7a2374e0f0c2a2dfd0b9d1bee90c129f2e72

Contents?: true

Size: 398 Bytes

Versions: 8

Compression:

Stored size: 398 Bytes

Contents

# frozen_string_literal: true

module RubyLokaliseApi
  module Concerns
    # Adds the `[]` method for invariant access
    module HashAccessible
      def [](raw_key_attr)
        key_attr = :"@#{raw_key_attr}"

        return nil unless instance_variables.include?(key_attr) && respond_to?(raw_key_attr.to_sym)

        instance_variable_get(key_attr)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ruby-lokalise-api-9.3.0 lib/ruby_lokalise_api/concerns/hash_accessible.rb
ruby-lokalise-api-9.2.1 lib/ruby_lokalise_api/concerns/hash_accessible.rb
ruby-lokalise-api-9.2.0 lib/ruby_lokalise_api/concerns/hash_accessible.rb
ruby-lokalise-api-9.0.1 lib/ruby_lokalise_api/concerns/hash_accessible.rb
ruby-lokalise-api-9.0.0 lib/ruby_lokalise_api/concerns/hash_accessible.rb
ruby-lokalise-api-8.0.1 lib/ruby_lokalise_api/concerns/hash_accessible.rb
ruby-lokalise-api-8.0.0 lib/ruby_lokalise_api/concerns/hash_accessible.rb
ruby-lokalise-api-8.0.0.rc1 lib/ruby_lokalise_api/concerns/hash_accessible.rb