Class: Literal::DataStructure Private
- Inherits:
-
Object
- Object
- Literal::DataStructure
- Extended by:
- Properties
- Defined in:
- lib/literal/data_structure.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary
Constants included from Types
Types::CallableType, Types::LambdaType, Types::NilableBooleanType, Types::NilableCallableType, Types::NilableJSONDataType, Types::NilableLambdaType, Types::NilableProcableType, Types::ProcableType
Class Method Summary collapse
- .__generate_literal_methods__(new_property, buffer = +"")) ⇒ Object private
- .from_pack(payload) ⇒ Object private
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?) private
- #as_pack ⇒ Object private
- #deconstruct ⇒ Object private
- #deconstruct_keys(keys) ⇒ Object private
- #hash ⇒ Object private
- #marshal_dump ⇒ Object private
- #marshal_load(payload) ⇒ Object private
- #to_h ⇒ Object (also: #to_hash) private
Methods included from Properties
extended, initialize, literal_properties, prop
Methods included from Types
#_Any, #_Any?, #_Array, #_Array?, #_Boolean, #_Boolean?, #_Callable, #_Callable?, #_Class, #_Class?, #_Constraint, #_Constraint?, #_Date, #_Date?, #_Deferred, #_Deferred?, #_Descendant, #_Descendant?, #_Enumerable, #_Enumerable?, #_Falsy, #_Float, #_Float?, #_Frozen, #_Frozen?, #_Hash, #_Hash?, #_Integer, #_Integer?, #_Interface, #_Interface?, #_Intersection, #_Intersection?, #_JSONData, #_JSONData?, #_Lambda, #_Lambda?, #_Map, #_Map?, #_Never, #_Nilable, #_Not, #_Pattern, #_Predicate, #_Procable, #_Procable?, #_Range, #_Range?, #_Set, #_Set?, #_String, #_String?, #_Symbol, #_Symbol?, #_Time, #_Time?, #_Truthy, #_Tuple, #_Tuple?, #_Union, #_Union?, #_Unit, #_Unit?, #_Void
Class Method Details
.__generate_literal_methods__(new_property, buffer = +"")) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
56 57 58 59 60 61 |
# File 'lib/literal/data_structure.rb', line 56 def self.__generate_literal_methods__(new_property, buffer = +"") super literal_properties.generate_hash(buffer) literal_properties.generate_eq(buffer) buffer end |
.from_pack(payload) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
7 8 9 10 11 |
# File 'lib/literal/data_structure.rb', line 7 def self.from_pack(payload) object = allocate object.marshal_load(payload) object end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
50 51 52 |
# File 'lib/literal/data_structure.rb', line 50 def ==(other) self.class === other && other.class.literal_properties.empty? end |
#as_pack ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 |
# File 'lib/literal/data_structure.rb', line 28 def as_pack marshal_dump end |
#deconstruct ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 |
# File 'lib/literal/data_structure.rb', line 19 def deconstruct to_h.values end |
#deconstruct_keys(keys) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 26 |
# File 'lib/literal/data_structure.rb', line 23 def deconstruct_keys(keys) h = to_h keys ? h.slice(*keys) : h end |
#hash ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
46 47 48 |
# File 'lib/literal/data_structure.rb', line 46 def hash self.class.hash end |
#marshal_dump ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 |
# File 'lib/literal/data_structure.rb', line 42 def marshal_dump [1, to_h, frozen?].freeze end |
#marshal_load(payload) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 35 36 37 38 39 40 |
# File 'lib/literal/data_structure.rb', line 32 def marshal_load(payload) _version, attributes, was_frozen = payload attributes.each do |key, value| instance_variable_set("@#{key}", value) end freeze if was_frozen end |
#to_h ⇒ Object Also known as: to_hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/literal/data_structure.rb', line 13 def to_h {} end |