Class: Literal::Data
- Inherits:
-
DataStructure
- Object
- DataStructure
- Literal::Data
- Defined in:
- lib/literal/data.rb
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
- .[] ⇒ Object
- .define(**properties) ⇒ Object
- .literal_properties ⇒ Object
- .prop(name, type, kind = :keyword, reader: :public, predicate: false, default: nil, description: nil) ⇒ Object
Methods inherited from DataStructure
#==, __generate_literal_methods__, #as_pack, #deconstruct, #deconstruct_keys, from_pack, #hash, #marshal_dump, #marshal_load, #to_h
Methods included from Properties
extended, #initialize, #literal_properties, #prop, #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?, #_Kind, #_Lambda, #_Lambda?, #_Map, #_Map?, #_Never, #_Nilable, #_Not, #_Pattern, #_Predicate, #_Procable, #_Procable?, #_Range, #_Range?, #_SameObject, #_SameObject?, #_Set, #_Set?, #_String, #_String?, #_Symbol, #_Symbol?, #_TaggedUnion, #_TaggedUnion?, #_Time, #_Time?, #_Truthy, #_Tuple, #_Tuple?, #_Union, #_Union?, #_Void
Class Method Details
.[] ⇒ Object
5 |
# File 'lib/literal/data.rb', line 5 def [](...) = new(...) |
.define(**properties) ⇒ Object
7 8 9 10 11 |
# File 'lib/literal/data.rb', line 7 def define(**properties) Class.new(self) do properties.each { |name, type| prop(name, type) } end end |
.literal_properties ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/literal/data.rb', line 17 def literal_properties return @literal_properties if defined?(@literal_properties) if superclass < Literal::Data @literal_properties = superclass.literal_properties.dup else @literal_properties = Literal::Properties::DataSchema.new end end |
.prop(name, type, kind = :keyword, reader: :public, predicate: false, default: nil, description: nil) ⇒ Object
13 14 15 |
# File 'lib/literal/data.rb', line 13 def prop(name, type, kind = :keyword, reader: :public, predicate: false, default: nil, description: nil) super(name, type, kind, reader:, writer: false, predicate:, default:, description:) end |