Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #45 from clearsightstudio/master

Added to_date_object method for use in finders
  • Loading branch information...
commit 3a357a6cb38b9b36b5c6d20b8893e855fae9e52d 2 parents bb2222f + dd8a903
@adelevie authored
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/parse_resource/base.rb
View
8 lib/parse_resource/base.rb
@@ -91,6 +91,10 @@ def to_pointer
{"__type" => "Pointer", "className" => klass_name, "objectId" => self.id}
end
+ def self.to_date_object(date)
+ {"__type" => "Date", "iso" => date.iso8601} if date && (date.is_a?(Date) || date.is_a?(DateTime) || date.is_a?(Time))
+ end
+
# Creates setter methods for model fields
def create_setters!(k,v)
unless self.respond_to? "#{k}="
@@ -402,8 +406,8 @@ def get_attribute(k)
def set_attribute(k, v)
if v.is_a?(Date) || v.is_a?(Time) || v.is_a?(DateTime)
v = {"__type" => "Date", "iso" => v.iso8601}
- else
- v = v.to_pointer if v.respond_to?(:to_pointer)
+ elsif v.respond_to?(:to_pointer)
+ v = v.to_pointer
end
@unsaved_attributes[k.to_s] = v unless v == @attributes[k.to_s] # || @unsaved_attributes[k.to_s]
@attributes[k.to_s] = v
Please sign in to comment.
Something went wrong with that request. Please try again.