Sha256: 1aade64514d237e352e41583ac38052effd82cf7d69380ead810efa2b8de086f

Contents?: true

Size: 969 Bytes

Versions: 2

Compression:

Stored size: 969 Bytes

Contents

module Turnkey

  module Proxy
    include Turnkey::Sanitizers

    #def self.included(base)
    #  base.extend(ClassMethods)
    #end

    def encodeWithCoder(encoder)
      #self.class.tk_vars = instance_variables
      instance_variables.each do |prop|
        reader_sig = reader_sig_for(prop)
        encoder.encodeObject(self.send(reader_sig), forKey: reader_sig)
      end
    end

    def initWithCoder(decoder)
      init.tap do
        property_list = Cache.attributesForClass(self.class)
        property_list.each do |prop|
          value = decoder.decodeObjectForKey(reader_sig_for(prop))
          self.send(writer_sig_for(prop), value) if value
        end
      end
    end

    #module ClassMethods
    #
    #  def tk_vars=(vars)
    #    instance_eval do
    #      @@vars ||= []
    #      @@vars = @@vars | vars
    #    end
    #  end
    #
    #  def tk_vars
    #    instance_eval do
    #      @@vars
    #    end
    #  end
    #end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
turnkey-0.2.2 lib/turnkey/proxy.rb
turnkey-0.2.1 ../lib/turnkey/proxy.rb