Module: ApiResource::Conditions::ClassMethods

Defined in:
lib/api_resource/conditions.rb

Instance Method Summary collapse

Instance Method Details

#includes(*args) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/api_resource/conditions.rb', line 19

def includes(*args)

	self.load_resource_definition

	# everything in args must be an association
	args.each do |arg|
		unless self.association?(arg)
			raise ArgumentError, "Unknown association #{arg} to eager load"
		end
	end

	# Everything looks good so just create the scope
	ApiResource::Conditions::IncludeCondition.new(self, args)

end

#paginate(opts = {}) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/api_resource/conditions.rb', line 35

def paginate(opts = {})
	self.load_resource_definition

	# Everything looks good so just create the scope
	ApiResource::Conditions::PaginationCondition.new(self, opts)

end

#where(opts = {}) ⇒ Object



43
44
45
46
47
# File 'lib/api_resource/conditions.rb', line 43

def where(opts = {})
	self.load_resource_definition

	ApiResource::Conditions::WhereCondition.new(self, opts)
end