Module: Surrealist::InstanceMethods
- Defined in:
- lib/surrealist/instance_methods.rb
Overview
Instance methods that are included to the object’s class
Instance Method Summary collapse
-
#build_schema(**args) ⇒ Object
Invokes
Surrealist
‘s class methodbuild_schema
. -
#surrealize(**args) ⇒ String
Dumps the object’s methods corresponding to the schema provided in the object’s class and type-checks the values.
Instance Method Details
#build_schema(**args) ⇒ Object
Invokes Surrealist
‘s class method build_schema
62 63 64 65 66 67 68 69 70 |
# File 'lib/surrealist/instance_methods.rb', line 62 def build_schema(**args) return args[:serializer].new(self).build_schema(**args) if args[:serializer] if (serializer = find_serializer(args[:for])) return serializer.new(self).build_schema(**args) end Surrealist.build_schema(instance: self, **args) end |
#surrealize(**args) ⇒ String
Dumps the object’s methods corresponding to the schema provided in the object’s class and type-checks the values.
51 52 53 54 55 56 57 58 59 |
# File 'lib/surrealist/instance_methods.rb', line 51 def surrealize(**args) return args[:serializer].new(self).surrealize(**args) if args[:serializer] if (serializer = find_serializer(args[:for])) return serializer.new(self).surrealize(**args) end Oj.dump(Surrealist.build_schema(instance: self, **args), mode: :compat) end |