Class: Rails::GraphQL::Type::Scalar::StringScalar
- Inherits:
-
Rails::GraphQL::Type::Scalar
- Object
- Rails::GraphQL::Type
- Rails::GraphQL::Type::Scalar
- Rails::GraphQL::Type::Scalar::StringScalar
- Defined in:
- lib/rails/graphql/type/scalar/string_scalar.rb
Overview
The String scalar type represents textual data, represented as UTF-8 character sequences.
Constant Summary
Constants inherited from Rails::GraphQL::Type
Class Method Summary collapse
Methods inherited from Rails::GraphQL::Type::Scalar
inspect, to_json, valid_output?
Methods inherited from Rails::GraphQL::Type
=~, base_type, create!, decorate, find_by_gid, gid_base_class, input_type?, kind, kind_enum, leaf_type?, operational?, output_type?, to_gql_backtrace
Methods included from Helpers::WithDirectives
#all_directive_events, #all_directive_listeners, #directive_events?, #directive_listeners?, extended, included, #initialize_copy, #use, #using?, #validate!
Methods included from Helpers::WithGlobalID
Methods included from Helpers::Registerable
#aliases, extended, #inherited, #register!, #registered?
Class Method Details
.as_json(value) ⇒ Object
23 24 25 26 27 |
# File 'lib/rails/graphql/type/scalar/string_scalar.rb', line 23 def as_json(value) value = value.to_s unless value.is_a?(String) value = value.encode(Encoding::UTF_8) unless value.encoding.eql?(Encoding::UTF_8) value end |
.deserialize(value) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/rails/graphql/type/scalar/string_scalar.rb', line 29 def deserialize(value) if valid_token?(value, :string) value[1..-2] # Remove the quotes elsif valid_token?(value, :heredoc) value[3..-4].strip_heredoc # Remove the quotes and fix indentation else value end end |
.valid_input?(value) ⇒ Boolean
19 20 21 |
# File 'lib/rails/graphql/type/scalar/string_scalar.rb', line 19 def valid_input?(value) super || valid_token?(value, :heredoc) end |