class Sanity::Http::Where
Attributes
groq[R]
groq_attributes[R]
use_post[R]
variables[R]
Public Class Methods
new(**args)
click to toggle source
Calls superclass method
Sanity::Http::Query::new
# File lib/sanity/http/where.rb, line 15 def initialize(**args) super @groq = args.delete(:groq) || "" @variables = args.delete(:variables) || {} @use_post = args.delete(:use_post) || false @groq_attributes = args.except(:groq, :use_post, :resource_klass, :result_wrapper) end
Private Instance Methods
groq_query()
click to toggle source
# File lib/sanity/http/where.rb, line 48 def groq_query groq.empty? ? Sanity::Groqify.call(**groq_attributes) : groq end
method()
click to toggle source
# File lib/sanity/http/where.rb, line 26 def method use_post ? :post : :get end
query_and_variables()
click to toggle source
# File lib/sanity/http/where.rb, line 36 def query_and_variables if use_post {params: variables} else {}.tap do |hash| variables.each do |key, value| hash["$#{key}"] = "\"#{value}\"" end end end.merge(query: groq_query) end
request_body()
click to toggle source
# File lib/sanity/http/where.rb, line 52 def request_body return unless use_post query_and_variables.to_json end
uri()
click to toggle source
Calls superclass method
Sanity::Http::Query#uri
# File lib/sanity/http/where.rb, line 30 def uri super.tap do |obj| obj.query = URI.encode_www_form(query_and_variables) unless use_post end end