Sha256: 3eaa0982c3e8ad38103b3b8dbbe743193d6b7ba2919bf5b0b43b5ffc21ae1634
Contents?: true
Size: 1.86 KB
Versions: 5
Compression:
Stored size: 1.86 KB
Contents
# frozen_string_literal: true module ConvenientService module Service module Plugins module HasResultSteps module Entities class Method module Commands ## # TODO: Replace `CastMethodKey`, `CastMethodName`, `CastMethodCaller` by declarative caster? # class CastMethodKey < Support::Command attr_reader :other, :options def initialize(other:, options:) @other = other @options = options end def call ## # TODO: Use pattern matcher when Ruby 2.7. # case other when ::Symbol then cast_symbol when ::String then cast_string when ::Hash then cast_hash when Method then cast_method end end private def cast_symbol Entities::Key.new(other) end def cast_string Entities::Key.new(other) end def cast_hash return unless other.keys.one? key = other.keys.first value = other.values.first case value when ::Symbol Entities::Key.new(key) when ::String Entities::Key.new(key) when ::Proc Entities::Key.new(key) when Entities::Values::Raw Entities::Key.new(key) end end def cast_method other.key.copy end end end end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems