Class: Types::DurationType
- Inherits:
-
BaseScalar
- Object
- GraphQL::Schema::Scalar
- BaseScalar
- Types::DurationType
- Defined in:
- app/graphql/types/duration_type.rb
Class Method Summary collapse
Class Method Details
.coerce_input(value, ctx) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/graphql/types/duration_type.rb', line 12 def self.coerce_input(value, ctx) case value when Float value when Integer value.to_f when NilClass raise GraphQL::CoercionError, 'Cannot be nil' else raise GraphQL::CoercionError, "Expected number: got #{value.class}" end end |
.coerce_result(value, ctx) ⇒ Object
25 26 27 |
# File 'app/graphql/types/duration_type.rb', line 25 def self.coerce_result(value, ctx) value.to_f end |