Class: Types::Typed

Inherits:
Object
  • Object
show all
Defined in:
lib/solidity/typed/typed.rb,
lib/solidity/typed/metatypes/bool.rb,
lib/solidity/typed/metatypes/array.rb,
lib/solidity/typed/metatypes/types.rb,
lib/solidity/typed/metatypes/mapping.rb,
lib/solidity/typed/metatypes/literals.rb

Overview

note: use class Typed as namespace (all metatype etc. nested here - the beginning)

Direct Known Subclasses

Enum, Event, Struct, TypedReference, TypedValue

Defined Under Namespace

Classes: AddressType, ArrayType, BoolType, Bytes32Type, BytesType, ContractType, DataType, EnumType, EventType, InscriptionIdType, IntType, MappingType, ReferenceType, StringType, StructType, TimedeltaType, TimestampType, Type, UIntType, ValueType

Constant Summary collapse

STRING_ZERO =

global literal constants

add LITERAL_ eg. LITERAL_STRING_ZERO - why? why not?
''.freeze
BYTES_ZERO =

string with utf-8 encoding

String.new().freeze
BYTES20_ZERO =

string with binary encoding

('0x'+'00'*20).freeze
BYTES32_ZERO =

32 bytes (64 hexchars)

('0x'+'00'*32).freeze
ADDRESS_ZERO =
BYTES20_ZERO
INSCRIPTION_ID_ZERO =
INSCRIPTIONID_ZERO = BYTES32_ZERO

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.dumpObject

use like:

  Typed.serialize( obj ) or
  Typed.dump( obj )
keep serialize/dump here in Typed - why? why not?


34
35
36
# File 'lib/solidity/typed/typed.rb', line 34

def self.serialize( obj )
   obj.as_data
end

.serialize(obj) ⇒ Object

use like:

  Typed.serialize( obj ) or
  Typed.dump( obj )
keep serialize/dump here in Typed - why? why not?


30
31
32
# File 'lib/solidity/typed/typed.rb', line 30

def self.serialize( obj )
   obj.as_data
end

.typeObject



39
40
41
# File 'lib/solidity/typed/typed.rb', line 39

def self.type      
  raise "no required typed class accessor/ getter method defined for Typed subclass #{self.class.name}; sorry"
end

Instance Method Details

#as_dataObject

kind of like as_json (in rails/ActiveModel/Serializers/JSON/as_json)



44
45
46
# File 'lib/solidity/typed/typed.rb', line 44

def as_data   ## kind of like as_json (in rails/ActiveModel/Serializers/JSON/as_json)
  raise "no required as_data method defined for Typed subclass #{self.class.name}; sorry"
end

#as_jsonObject



51
# File 'lib/solidity/typed/typed.rb', line 51

def as_json()   as_data; end

#serializeObject

keep serialize and/or as_json - why? why not?



50
# File 'lib/solidity/typed/typed.rb', line 50

def serialize() as_data; end

#typeObject



42
# File 'lib/solidity/typed/typed.rb', line 42

def type() self.class.type; end