Module: DurableHuggingfaceHub::Struct::Loadable
- Defined in:
- lib/durable_huggingface_hub/types.rb
Overview
Base class for data structures that can be loaded from JSON/Hash.
Provides convenient methods for creating instances from API responses.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Struct
Creates an instance from a hash (typically from JSON parsing).
Instance Method Summary collapse
-
#to_h ⇒ Hash
Converts the struct to a hash.
-
#to_json(*args) ⇒ String
Converts the struct to JSON.
Class Method Details
.included(base) ⇒ Struct
Creates an instance from a hash (typically from JSON parsing).
169 170 171 |
# File 'lib/durable_huggingface_hub/types.rb', line 169 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#to_h ⇒ Hash
Converts the struct to a hash.
192 193 194 |
# File 'lib/durable_huggingface_hub/types.rb', line 192 def to_h attributes.to_h end |
#to_json(*args) ⇒ String
Converts the struct to JSON.
199 200 201 202 |
# File 'lib/durable_huggingface_hub/types.rb', line 199 def to_json(*args) require "json" to_h.to_json(*args) end |