class Serde::Serializer
Attributes
descendants[R]
Public Class Methods
compile!()
click to toggle source
# File lib/serde.rb, line 30 def compile! raise 'already compiled' if @compiled Dir.mktmpdir do |dir| Dir.chdir(dir) do SerializerGenerator.call(dir, self) rust_path = File.expand_path('../rust', __dir__) `cd #{rust_path}; cargo +beta build --release` `cp #{rust_path}/target/release/libserde_rb*.a #{dir}/serde_rb/libserde_rb.a` `cd #{dir}/serde_rb; ruby extconf.rb; make clean; make` require_relative "#{dir}/serde_rb/serde_rb" end end @compiled = true end
get_schema()
click to toggle source
# File lib/serde.rb, line 50 def get_schema @schema end
inherited(klass)
click to toggle source
# File lib/serde.rb, line 22 def inherited(klass) @descendants << klass end
new(object)
click to toggle source
# File lib/serde.rb, line 55 def initialize(object) @args = self.class.get_schema.keys.map { |k| object.public_send(k) } end
schema(**attrs)
click to toggle source
# File lib/serde.rb, line 26 def schema(**attrs) @schema = attrs end
Public Instance Methods
to_json()
click to toggle source
# File lib/serde.rb, line 59 def to_json internal_to_json(*@args) end