Sha256: 9220084fe1964da9d09eadeef95a39b7a8fa2aaec6f0df6c5971f0828e922152

Contents?: true

Size: 389 Bytes

Versions: 1

Compression:

Stored size: 389 Bytes

Contents

# frozen_string_literal: true

class KeyMapable::Accessor
  class Method
    def self.access(subject, key)
      subject.public_send(key)
    end
  end

  class Hash
    def self.access(subject, key)
      subject[key]
    end
  end

  ACCESSORS = {
    method: Method,
    hash: Hash
  }

  def self.for(accessor_or_name)
    ACCESSORS.fetch(accessor_or_name, accessor_or_name)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
key_mapable-0.6.0 lib/key_mapable/accessor.rb