Module: Ciri::RLP::Serializable::ClassMethods

Defined in:
lib/ciri/rlp/serializable.rb

Instance Method Summary collapse

Instance Method Details

#default_data(data = nil) ⇒ Object


159
160
161
# File 'lib/ciri/rlp/serializable.rb', line 159

def default_data(data = nil)
  @default_data ||= data
end

#rlp_decode(input, raw: true) ⇒ Object Also known as: rlp_decode!

Decode object from input


145
146
147
148
# File 'lib/ciri/rlp/serializable.rb', line 145

def rlp_decode(input, raw: true)
  data = schema.rlp_decode!(input, raw: raw)
  self.new(data)
end

#schema(data_schema = nil) ⇒ Object


152
153
154
155
156
157
# File 'lib/ciri/rlp/serializable.rb', line 152

def schema(data_schema = nil)
  @data_schema ||= Schema.new(data_schema).tap do |schema|
    # define attributes methods
    define_attributes(schema)
  end
end