Class: Rails::GraphQL::Type::Scalar::BooleanScalar
- Inherits:
-
Rails::GraphQL::Type::Scalar
- Object
- Rails::GraphQL::Type
- Rails::GraphQL::Type::Scalar
- Rails::GraphQL::Type::Scalar::BooleanScalar
- Defined in:
- lib/rails/graphql/type/scalar/boolean_scalar.rb
Overview
The Boolean scalar type represents true
or false
.
Constant Summary collapse
- FALSE_VALUES =
::ActiveModel::Type::Boolean::FALSE_VALUES
Constants inherited from Rails::GraphQL::Type
Class Method Summary collapse
- .as_json(value) ⇒ Object
- .deserialize(value) ⇒ Object
- .valid_input?(value) ⇒ Boolean
- .valid_output? ⇒ Boolean
Methods inherited from Rails::GraphQL::Type::Scalar
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
26 27 28 |
# File 'lib/rails/graphql/type/scalar/boolean_scalar.rb', line 26 def as_json(value) !(value.nil? || FALSE_VALUES.include?(value)) end |
.deserialize(value) ⇒ Object
30 31 32 |
# File 'lib/rails/graphql/type/scalar/boolean_scalar.rb', line 30 def deserialize(value) as_json(value) end |
.valid_input?(value) ⇒ Boolean
18 19 20 |
# File 'lib/rails/graphql/type/scalar/boolean_scalar.rb', line 18 def valid_input?(value) valid_token?(value) || value === true || value === false end |
.valid_output? ⇒ Boolean
22 23 24 |
# File 'lib/rails/graphql/type/scalar/boolean_scalar.rb', line 22 def valid_output?(*) true # Pretty much anything can be turned into a boolean end |