Sha256: d3dc2ed53dcdff00023ff026fa072ebb9699038a1f013df6c55df197ce1293a4
Contents?: true
Size: 1.31 KB
Versions: 3
Compression:
Stored size: 1.31 KB
Contents
module ParseModel module User attr_accessor :PFUser RESERVED_KEYS = ['username', 'password', 'email'] def initialize @PFUser = PFUser.user end def method_missing(method, *args, &block) if RESERVED_KEYS.include?(method) @PFUser.send(method) elsif RESERVED_KEYS.map {|f| "#{f}="}.include?("#{method}") @PFUser.send(method, args.first) elsif fields.include?(method) @PFUser.objectForKey(method) elsif fields.map {|f| "#{f}="}.include?("#{method}") method = method.split("=")[0] @PFUser.setObject(args.first, forKey:method) elsif @PFUser.respond_to?(method) @PFUser.send(method, *args, &block) else super end end def fields self.class.send(:get_fields) end module ClassMethods def fields(*args) args.each {|arg| field(arg)} end def field(name) @fields end def current_user if PFUser.currentUser u = new u.PFUser = PFUser.currentUser return u else return nil end end def get_fields @fields ||= [] @fields end end def self.included(base) base.extend(ClassMethods) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ParseModel-0.0.6 | lib/ParseModel/User.rb |
ParseModel-0.0.5 | lib/ParseModel/User.rb |
ParseModel-0.0.4 | lib/ParseModel/User.rb |