Module: Ciri::RLP::Serializable::ClassMethods
- Defined in:
- lib/ciri/rlp/serializable.rb
Instance Method Summary collapse
- #default_data(data = nil) ⇒ Object
-
#rlp_decode(input) ⇒ Object
Decode object from input.
-
#rlp_encode(item, skip_keys: nil, white_list_keys: nil) ⇒ Object
Encode object to rlp encoding string.
- #schema(data_schema = nil) ⇒ Object
Instance Method Details
#default_data(data = nil) ⇒ Object
185 186 187 |
# File 'lib/ciri/rlp/serializable.rb', line 185 def default_data(data = nil) @default_data ||= data end |
#rlp_decode(input) ⇒ Object
Decode object from input
168 169 170 171 |
# File 'lib/ciri/rlp/serializable.rb', line 168 def rlp_decode(input) data = schema.rlp_decode(input) self.new(data) end |
#rlp_encode(item, skip_keys: nil, white_list_keys: nil) ⇒ Object
Encode object to rlp encoding string
174 175 176 |
# File 'lib/ciri/rlp/serializable.rb', line 174 def rlp_encode(item, skip_keys: nil, white_list_keys: nil) schema.rlp_encode(item.serializable_attributes, skip_keys: skip_keys, white_list_keys: white_list_keys) end |
#schema(data_schema = nil) ⇒ Object
178 179 180 181 182 183 |
# File 'lib/ciri/rlp/serializable.rb', line 178 def schema(data_schema = nil) @data_schema ||= Schema.new(data_schema).tap do |schema| # define attributes methods define_attributes(schema) end end |