Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

moved query methods into...ParseResource::QueryMethods

  • Loading branch information...
commit e6be1e478de6f93812b7dc2f2e2b417b210f813b 1 parent 34c4449
@adelevie authored
View
2  lib/parse_resource.rb
@@ -1,4 +1,6 @@
require 'parse_resource/base'
+require 'parse_resource/query_methods'
+require 'parse_resource/client'
require 'parse_resource/query'
require 'parse_resource/parse_user'
require 'parse_resource/parse_user_validator'
View
41 lib/parse_resource/base.rb
@@ -6,6 +6,7 @@
require "json"
require "active_support/hash_with_indifferent_access"
require "parse_resource/query"
+require "parse_resource/query_methods"
require "parse_resource/parse_error"
require "parse_resource/parse_exceptions"
@@ -227,47 +228,9 @@ def self.where(*args)
Query.new(self).where(*args)
end
- # Include the attributes of a parent ojbect in the results
- # Similar to ActiveRecord eager loading
- #
- def self.include_object(parent)
- Query.new(self).include_object(parent)
- end
-
- # Add this at the end of a method chain to get the count of objects, instead of an Array of objects
- def self.count
- #https://www.parse.com/docs/rest#queries-counting
- Query.new(self).count(1)
- end
- # Find all ParseResource::Base objects for that model.
- #
- # @return [Array] an `Array` of objects that subclass `ParseResource`.
- def self.all
- Query.new(self).all
- end
+ include ParseResource::QueryMethods
- # Find the first object. Fairly random, not based on any specific condition.
- #
- def self.first
- Query.new(self).limit(1).first
- end
-
- # Limits the number of objects returned
- #
- def self.limit(n)
- Query.new(self).limit(n)
- end
-
- # Skip the number of objects
- #
- def self.skip(n)
- Query.new(self).skip(n)
- end
-
- #def self.order(attribute)
- # Query.new(self).order(attribute)
- #end
# Create a ParseResource::Base object.
#
View
8 lib/parse_resource/client.rb
@@ -0,0 +1,8 @@
+require "rest-client"
+require "json"
+
+module ParseResource
+ class Client
+
+ end
+end
View
56 lib/parse_resource/query_methods.rb
@@ -0,0 +1,56 @@
+#require 'parse_resource'
+require 'parse_resource/query'
+
+module ParseResource
+
+ module QueryMethods
+
+ module ClassMethods
+ # Include the attributes of a parent ojbect in the results
+ # Similar to ActiveRecord eager loading
+ #
+ def include_object(parent)
+ Query.new(self).include_object(parent)
+ end
+
+ # Add this at the end of a method chain to get the count of objects, instead of an Array of objects
+ def count
+ #https://www.parse.com/docs/rest#queries-counting
+ Query.new(self).count(1)
+ end
+
+ # Find all ParseResource::Base objects for that model.
+ #
+ # @return [Array] an `Array` of objects that subclass `ParseResource`.
+ def all
+ Query.new(self).all
+ end
+
+ # Find the first object. Fairly random, not based on any specific condition.
+ #
+ def first
+ Query.new(self).limit(1).first
+ end
+
+ # Limits the number of objects returned
+ #
+ def limit(n)
+ Query.new(self).limit(n)
+ end
+
+ # Skip the number of objects
+ #
+ def skip(n)
+ Query.new(self).skip(n)
+ end
+
+ #def self.order(attribute)
+ # Query.new(self).order(attribute)
+ #end
+ end
+
+ def self.included(base)
+ base.extend(ClassMethods)
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.