class GraphQLSwiftGen::Scalar
Attributes
json_type[R]
swift_type[R]
type_name[R]
Public Class Methods
new(type_name:, swift_type:, json_type: 'String', serialize_expr: nil, deserialize_expr: nil)
click to toggle source
# File codegen/lib/graphql_swift_gen/scalar.rb, line 5 def initialize(type_name:, swift_type:, json_type: 'String', serialize_expr: nil, deserialize_expr: nil) @type_name = type_name @swift_type = swift_type @json_type = json_type @serialize_expr = serialize_expr || ->(expr) { expr } @deserialize_expr = deserialize_expr || ->(expr) { expr } end
Public Instance Methods
deserialize_expr(expr)
click to toggle source
# File codegen/lib/graphql_swift_gen/scalar.rb, line 22 def deserialize_expr(expr) @deserialize_expr.call(expr) end
serialize_expr(expr)
click to toggle source
# File codegen/lib/graphql_swift_gen/scalar.rb, line 13 def serialize_expr(expr) expr = @serialize_expr.call(expr) if json_type == 'String' expr = "\"\\(#{expr})\"" unless swift_type == 'String' expr = "GraphQL.quoteString(input: #{expr})" end "\\(#{expr})" end