Class: Lutaml::Store::Format::Jsonl

Inherits:
Base
  • Object
show all
Defined in:
lib/lutaml/store/format/jsonl.rb

Instance Method Summary collapse

Instance Method Details

#deserialize(data, model_class) ⇒ Object



23
24
25
# File 'lib/lutaml/store/format/jsonl.rb', line 23

def deserialize(data, model_class)
  model_class.from_json(data)
end

#deserialize_many(data, model_class) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/lutaml/store/format/jsonl.rb', line 27

def deserialize_many(data, model_class)
  data.lines.filter_map do |line|
    next if line.strip.empty?

    model_class.from_json(line)
  end
end

#extensionObject



7
8
9
# File 'lib/lutaml/store/format/jsonl.rb', line 7

def extension
  ".jsonl"
end

#glob_patternObject



11
12
13
# File 'lib/lutaml/store/format/jsonl.rb', line 11

def glob_pattern
  "*.jsonl"
end

#serialize(model) ⇒ Object



15
16
17
# File 'lib/lutaml/store/format/jsonl.rb', line 15

def serialize(model)
  model.to_json
end

#serialize_many(models) ⇒ Object



19
20
21
# File 'lib/lutaml/store/format/jsonl.rb', line 19

def serialize_many(models)
  "#{models.map(&:to_json).join("\n")}\n"
end