Module: Turnkey::Proxy

Includes:
Sanitizers
Defined in:
lib/turnkey/proxy.rb

Instance Method Summary collapse

Methods included from Sanitizers

#reader_sig_for, #writer_sig_for

Instance Method Details

#encodeWithCoder(encoder) ⇒ Object

def self.included(base)

base.extend(ClassMethods)

end



10
11
12
13
14
15
16
# File 'lib/turnkey/proxy.rb', line 10

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

#initWithCoder(decoder) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/turnkey/proxy.rb', line 18

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