Sha256: 6209713896e5900fff1cebaa976980c94684cf72d6646987c2724378b2a83e51

Contents?: true

Size: 464 Bytes

Versions: 6

Compression:

Stored size: 464 Bytes

Contents

require 'parameters/types/object'

module Parameters
  module Types
    class Symbol < Object

      #
      # Coerces a value into a Symbol.
      #
      # @param [#to_sym, #to_s] value
      #   The value to coerce.
      #
      # @return [::Symbol]
      #   The coerced Symbol.
      #
      def self.coerce(value)
        if value.respond_to?(:to_sym)
          value.to_sym
        else
          value.to_s.to_sym
        end
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
parameters-0.4.4 lib/parameters/types/symbol.rb
parameters-0.4.3 lib/parameters/types/symbol.rb
parameters-0.4.2 lib/parameters/types/symbol.rb
parameters-0.4.0 lib/parameters/types/symbol.rb
parameters-0.3.1 lib/parameters/types/symbol.rb
parameters-0.3.0 lib/parameters/types/symbol.rb