Class: Rails::GraphQL::Type::Scalar::IntScalar
- Inherits:
-
Rails::GraphQL::Type::Scalar
- Object
- Rails::GraphQL::Type
- Rails::GraphQL::Type::Scalar
- Rails::GraphQL::Type::Scalar::IntScalar
- Defined in:
- lib/rails/graphql/type/scalar/int_scalar.rb
Overview
The Int scalar type represents a signed 32-bit numeric non-fractional value.
Constant Summary collapse
- RANGE =
(-max_value...max_value).freeze
Constants inherited from Rails::GraphQL::Type
Class Method Summary collapse
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
29 30 31 32 |
# File 'lib/rails/graphql/type/scalar/int_scalar.rb', line 29 def as_json(value) value = value.to_i value if RANGE.cover?(value) end |
.valid_input?(value) ⇒ Boolean
20 21 22 23 |
# File 'lib/rails/graphql/type/scalar/int_scalar.rb', line 20 def valid_input?(value) (valid_token?(value) && RANGE.cover?(value.to_i)) || (value.is_a?(Integer) && RANGE.cover?(value)) end |
.valid_output?(value) ⇒ Boolean
25 26 27 |
# File 'lib/rails/graphql/type/scalar/int_scalar.rb', line 25 def valid_output?(value) value.respond_to?(:to_i) && RANGE.cover?(value.to_i) end |