Sha256: 71cd336b17f6a8f7fb9c7ce028db4eb5b56baa2a43e49538774a2cd84b87a36f
Contents?: true
Size: 963 Bytes
Versions: 23
Compression:
Stored size: 963 Bytes
Contents
require 'miasma' module Miasma module Types # Base data container class Data include Miasma::Utils::Lazy attribute :id, [String, Numeric] # Build new data instance # # @param args [Hash] attribute values # @return [self] def initialize(args={}) load_data(args) valid_state end # Convert model to JSON string # # @return [String] def to_json(*_) MultiJson.dump(attributes) end # Load model using JSON string # # @param json [String] # @return [self] def from_json(json) load_data( MultiJson.load(json).to_smash ).valid_state end class << self # Build new instance from JSON string # # @param json [String] # @return [Data] def from_json(json) self.new(MultiJson.load(json).to_smash) end end end end end
Version data entries
23 entries across 23 versions & 1 rubygems