Sha256: 7c3c9cfdedddac2fa178c59d12385f9cdb15ff9b9c4f38dc64edb50156695dc7
Contents?: true
Size: 1.09 KB
Versions: 5
Compression:
Stored size: 1.09 KB
Contents
module Formotion class Base def initialize(params = {}) params.each { |key, value| if self.class.const_get(:PROPERTIES).member? key.to_sym self.send((key.to_s + "=:").to_sym, value) end } end def to_hash h = {} self.class.const_get(:PROPERTIES).each { |prop| val = self.send(prop) h[prop] = val if val } h end # NSCoding + NSCopying def encodeWithCoder(encoder) self.class.const_get(:SERIALIZE_PROPERTIES).each {|prop| encoder.encodeObject(self.send(prop), forKey: prop.to_s) } end def initWithCoder(decoder) self.init self.class.const_get(:SERIALIZE_PROPERTIES).each {|prop| value = decoder.decodeObjectForKey(prop.to_s) self.send((prop.to_s + "=:").to_sym, value) if not value.nil? } self end def copyWithZone(zone) copy = self.class.allocWithZone(zone).init self.class.const_get(:SERIALIZE_PROPERTIES).each {|prop| copy.send((prop.to_s + "=:").to_sym, self.send(prop)) } copy end end end
Version data entries
5 entries across 5 versions & 1 rubygems