class ActiveAttr::Typecasting::StringTypecaster

Typecasts an Object to a String

@example Usage

StringTypecaster.new.call(1) #=> "1"

@since 0.5.0

Public Instance Methods

call(value) click to toggle source

Typecasts an object to a String

Attempts to convert using to_s.

@example Typecast an Integer

typecaster.call(1) #=> "1"

@param [Object, to_s] value The object to typecast

@return [String, nil] The result of typecasting

@since 0.5.0

# File lib/active_attr/typecasting/string_typecaster.rb, line 22
def call(value)
  value.to_s if value.respond_to? :to_s
end