Parsistence 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  *.gem
2
2
  .bundle
3
+ .repl_history
3
4
  Gemfile.lock
4
5
  pkg/*
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # About
2
2
 
3
- Parsistence provides an Active Record pattern to your Parse models on RubyMotion.
3
+ Parsistence provides an Active Record pattern to your Parse.com models on RubyMotion.
4
4
  It's an early fork from [ParseModel](https://github.com/adelevie/ParseModel) by
5
5
  Alan deLevie but goes a different direction with its implementation.
6
6
 
@@ -1,7 +1,7 @@
1
1
  module Parsistence
2
2
  module Model
3
3
  module ClassMethods
4
- QUERY_STUBS = [ :where, :first, :limit, :order, :eq, :notEq, :lt, :gt, :lte, :gte ] # :limit is different
4
+ QUERY_STUBS = [ :where, :first, :limit, :order, :eq, :notEq, :lt, :gt, :lte, :gte, :in ] # :limit is different
5
5
 
6
6
  def fetchAll(&block)
7
7
  q = Parsistence::Query.new
@@ -58,6 +58,7 @@ module Parsistence
58
58
  @gtConditions = {}
59
59
  @lteConditions = {}
60
60
  @gteConditions = {}
61
+ @inConditions = {}
61
62
  @order = {}
62
63
  @limit = nil
63
64
  @offset = nil
@@ -74,6 +75,10 @@ module Parsistence
74
75
  value = value.PFObject if value.respond_to? :PFObject
75
76
  query.whereKey(key, equalTo: value)
76
77
  end
78
+ @inConditions.each do |key, value|
79
+ value = value.PFObject if value.respond_to? :PFObject
80
+ query.whereKey(key, containedIn: value)
81
+ end
77
82
  @negativeConditions.each do |key, value|
78
83
  value = value.PFObject if value.respond_to? :PFObject
79
84
  query.whereKey(key, notEqualTo: value)
@@ -168,6 +173,7 @@ module Parsistence
168
173
  $stderr.puts "gtConditions: #{@gtConditions.to_s}"
169
174
  $stderr.puts "lteConditions: #{@lteConditions.to_s}"
170
175
  $stderr.puts "gteConditions: #{@gteConditions.to_s}"
176
+ $stderr.puts "inConditions: #{@inConditions.to_s}"
171
177
  $stderr.puts "order: #{@order.to_s}"
172
178
  $stderr.puts "limit: #{@limit.to_s}"
173
179
  $stderr.puts "offset: #{@offset.to_s}"
@@ -219,6 +225,13 @@ module Parsistence
219
225
  self
220
226
  end
221
227
 
228
+ def in(*fields)
229
+ fields.each do |field|
230
+ @inConditions.merge! field
231
+ end
232
+ self
233
+ end
234
+
222
235
  def lte(*fields)
223
236
  fields.each do |field|
224
237
  @lteConditions.merge! field
@@ -1,6 +1,6 @@
1
1
  module Parsistence
2
2
  module User
3
- include ::Parsistence::Model
3
+ include Parsistence::Model
4
4
 
5
5
  attr_accessor :PFUser
6
6
 
@@ -25,7 +25,9 @@ module Parsistence
25
25
  self.PFObject = value
26
26
  end
27
27
 
28
- module ClassMethods
28
+ module ClassMethods
29
+ include Parsistence::Model::ClassMethods
30
+
29
31
  def all
30
32
  query = PFQuery.queryForUser
31
33
  users = query.findObjects
@@ -33,7 +35,15 @@ module Parsistence
33
35
  end
34
36
 
35
37
  def currentUser
36
- PFUser.currentUser
38
+ return PFUser.currentUser if PFUser.currentUser
39
+ nil
40
+ end
41
+
42
+ def current_user
43
+ if PFUser.currentUser
44
+ return @current_user ||= self.new(PFUser.currentUser)
45
+ end
46
+ nil
37
47
  end
38
48
  end
39
49
 
@@ -1,3 +1,3 @@
1
1
  module Parsistence
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Parsistence
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-09-12 00:00:00.000000000 Z
14
+ date: 2012-09-26 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description: Your models on RubyMotion and Parse in a persistence.js style pattern.
17
17
  email: