class Formotion::Base

Public Class Methods

new(params = {}) click to toggle source
# File lib/formotion/base.rb, line 5
def initialize(params = {})
  params.each { |key, value|
    if  self.class.const_get(:PROPERTIES).member? key.to_sym
      self.send("#{key}=".to_sym, value)
    end
  }
end

Public Instance Methods

copyWithZone(zone) click to toggle source
# File lib/formotion/base.rb, line 53
def copyWithZone(zone)
  copy = self.class.allocWithZone(zone).init
  self.class.const_get(:SERIALIZE_PROPERTIES).each {|prop|
    copy.send("#{prop}=".to_sym, self.send(prop))
  }
  copy
end
encodeWithCoder(encoder) click to toggle source

NSCoding + NSCopying

# File lib/formotion/base.rb, line 38
def encodeWithCoder(encoder)
  self.class.const_get(:SERIALIZE_PROPERTIES).each {|prop|
    encoder.encodeObject(self.send(prop), forKey: prop.to_s)
  }
end
hash() click to toggle source

Needed so things like @targets with KVO

(storing Row instances as keys of a hash)
# File lib/formotion/base.rb, line 25
def hash
  "#{self.class.name}-id-#{object_id}".hash
end
initWithCoder(decoder) click to toggle source
# File lib/formotion/base.rb, line 44
def initWithCoder(decoder)
  self.init
  self.class.const_get(:SERIALIZE_PROPERTIES).each {|prop|
    value = decoder.decodeObjectForKey(prop.to_s)
    self.send("#{prop}=".to_sym, value) if not value.nil?
  }
  self
end
isEqual(other) click to toggle source
# File lib/formotion/base.rb, line 29
def isEqual(other)
  return true if other == self
  return false unless other # if other is nil
  return false unless other.class == self.class

  return other.object_id == self.object_id
end
to_hash() click to toggle source
# File lib/formotion/base.rb, line 13
def to_hash
  h = {}
   self.class.const_get(:PROPERTIES).each { |prop|
    val = self.send(prop)
    h[prop] = val if val
  }
  h
end