Sha256: 4f7a7ff3f7ab0b0e2c6aa8c044f43b649b19f31fac31d23ff0d81e8970d7559e
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 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 get_fields @fields ||= [] @fields end def all query = PFQuery.queryForUser users = query.findObjects users end end def self.included(base) base.extend(ClassMethods) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ParseModel-0.0.3 | lib/ParseModel/User.rb |