Sha256: 3297703f7585fafa11e5974769d616536b334c0062909d4d7f6f5739f0440843
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true # Checks the reader privacy # module Dry module Initializer module Dispatchers module PrepareReader extend self def call(target: nil, reader: :public, **options) reader = case reader.to_s when "false", "" then nil when "true" then :public when "public", "private", "protected" then reader.to_sym else invalid_reader!(target, reader) end {target: target, reader: reader, **options} end private def invalid_reader!(target, _reader) raise ArgumentError, <<~MESSAGE Invalid setting for the ##{target} reader's privacy. Use the one of the following values for the `:reader` option: - 'public' (true) for the public reader (default) - 'private' for the private reader - 'protected' for the protected reader - nil (false) if no reader should be defined MESSAGE end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dry-initializer-3.1.1 | lib/dry/initializer/dispatchers/prepare_reader.rb |
dry-initializer-3.1.0 | lib/dry/initializer/dispatchers/prepare_reader.rb |