Parsistence 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -129,10 +129,21 @@ module Parsistence
129
129
  end
130
130
  saved
131
131
  end
132
-
133
132
  def before_save; end
134
133
  def after_save; end
135
134
 
135
+ def delete
136
+ deleted = false
137
+ unless before_delete == false
138
+ deleted = @PFObject.delete
139
+ end
140
+ after_delete if deleted
141
+ deleted
142
+ end
143
+ def before_delete; end
144
+ def after_delete; end
145
+
146
+
136
147
  # Validations
137
148
  def presenceValidations
138
149
  self.class.send(:get_presence_validations)
@@ -152,7 +163,7 @@ module Parsistence
152
163
 
153
164
  def validateField(field, value)
154
165
  @errors ||= {}
155
- if presenceValidations.include?(field) && value.nil? || value == ""
166
+ if presenceValidations.include?(field) && (value.nil? || value == "")
156
167
  messages = presenceValidationMessages
157
168
  if messages.include?(field)
158
169
  @errors[field] = messages[field]
@@ -72,31 +72,31 @@ module Parsistence
72
72
  end
73
73
 
74
74
  @conditions.each do |key, value|
75
- value = value.PFObject if value.respond_to? :PFObject
75
+ value = value.PFObject if value.respond_to?(:PFObject)
76
76
  query.whereKey(key, equalTo: value)
77
77
  end
78
78
  @inConditions.each do |key, value|
79
- value = value.PFObject if value.respond_to? :PFObject
79
+ value = value.PFObject if value.respond_to?(:PFObject)
80
80
  query.whereKey(key, containedIn: value)
81
81
  end
82
82
  @negativeConditions.each do |key, value|
83
- value = value.PFObject if value.respond_to? :PFObject
83
+ value = value.PFObject if value.respond_to?(:PFObject)
84
84
  query.whereKey(key, notEqualTo: value)
85
85
  end
86
86
  @ltConditions.each do |key, value|
87
- value = value.PFObject if value.respond_to? :PFObject
87
+ value = value.PFObject if value.respond_to?(:PFObject)
88
88
  query.whereKey(key, lessThan: value)
89
89
  end
90
90
  @gtConditions.each do |key, value|
91
- value = value.PFObject if value.respond_to? :PFObject
91
+ value = value.PFObject if value.respond_to?(:PFObject)
92
92
  query.whereKey(key, greaterThan: value)
93
93
  end
94
94
  @lteConditions.each do |key, value|
95
- value = value.PFObject if value.respond_to? :PFObject
95
+ value = value.PFObject if value.respond_to?(:PFObject)
96
96
  query.whereKey(key, lessThanOrEqualTo: value)
97
97
  end
98
98
  @gteConditions.each do |key, value|
99
- value = value.PFObject if value.respond_to? :PFObject
99
+ value = value.PFObject if value.respond_to?(:PFObject)
100
100
  query.whereKey(key, greaterThanOrEqualTo: value)
101
101
  end
102
102
  first = true
@@ -156,13 +156,12 @@ module Parsistence
156
156
  end
157
157
 
158
158
  def all(&callback)
159
- fetch(&callback)
159
+ fetchAll(&callback)
160
160
  nil
161
161
  end
162
162
 
163
163
  def first(&callback)
164
- limit(0, 1)
165
- fetch(&callback)
164
+ fetchOne(&callback)
166
165
  nil
167
166
  end
168
167
 
@@ -45,6 +45,11 @@ module Parsistence
45
45
  end
46
46
  nil
47
47
  end
48
+
49
+ def log_out
50
+ @current_user = nil
51
+ PFUser.logOut
52
+ end
48
53
  end
49
54
 
50
55
  def self.included(base)
@@ -1,3 +1,3 @@
1
1
  module Parsistence
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
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.2
4
+ version: 0.3.3
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-26 00:00:00.000000000 Z
14
+ date: 2012-10-10 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: