Module: Bootsnap::CompileCache::JSON
- Defined in:
- lib/bootsnap/compile_cache/json.rb
Defined Under Namespace
Modules: Patch
Class Attribute Summary collapse
-
.cache_dir ⇒ Object
Returns the value of attribute cache_dir.
-
.msgpack_factory ⇒ Object
Returns the value of attribute msgpack_factory.
-
.supported_options ⇒ Object
Returns the value of attribute supported_options.
Class Method Summary collapse
- .init! ⇒ Object
- .input_to_output(data, kwargs) ⇒ Object
- .input_to_storage(payload, _) ⇒ Object
- .install!(cache_dir) ⇒ Object
- .precompile(path) ⇒ Object
- .storage_to_output(data, kwargs) ⇒ Object
Class Attribute Details
.cache_dir ⇒ Object
Returns the value of attribute cache_dir.
10 11 12 |
# File 'lib/bootsnap/compile_cache/json.rb', line 10 def cache_dir @cache_dir end |
.msgpack_factory ⇒ Object
Returns the value of attribute msgpack_factory.
9 10 11 |
# File 'lib/bootsnap/compile_cache/json.rb', line 9 def msgpack_factory @msgpack_factory end |
.supported_options ⇒ Object
Returns the value of attribute supported_options.
9 10 11 |
# File 'lib/bootsnap/compile_cache/json.rb', line 9 def @supported_options end |
Class Method Details
.init! ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/bootsnap/compile_cache/json.rb', line 48 def init! require "json" require "msgpack" self.msgpack_factory = MessagePack::Factory.new self. = [:symbolize_names] if supports_freeze? self. = [:freeze] end .freeze end |
.input_to_output(data, kwargs) ⇒ Object
28 29 30 |
# File 'lib/bootsnap/compile_cache/json.rb', line 28 def input_to_output(data, kwargs) ::JSON.parse(data, **(kwargs || {})) end |
.input_to_storage(payload, _) ⇒ Object
16 17 18 19 |
# File 'lib/bootsnap/compile_cache/json.rb', line 16 def input_to_storage(payload, _) obj = ::JSON.parse(payload) msgpack_factory.dump(obj) end |
.install!(cache_dir) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/bootsnap/compile_cache/json.rb', line 40 def install!(cache_dir) self.cache_dir = cache_dir init! if ::JSON.respond_to?(:load_file) ::JSON.singleton_class.prepend(Patch) end end |
.precompile(path) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/bootsnap/compile_cache/json.rb', line 32 def precompile(path) Bootsnap::CompileCache::Native.precompile( cache_dir, path.to_s, self, ) end |
.storage_to_output(data, kwargs) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/bootsnap/compile_cache/json.rb', line 21 def storage_to_output(data, kwargs) if kwargs&.key?(:symbolize_names) kwargs[:symbolize_keys] = kwargs.delete(:symbolize_names) end msgpack_factory.load(data, kwargs) end |