Class: Sanity::Groq::Order
- Inherits:
-
Object
- Object
- Sanity::Groq::Order
- Defined in:
- lib/sanity/groq/order.rb
Constant Summary collapse
- RESERVED =
%i[order]
Instance Attribute Summary collapse
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#val ⇒ Object
readonly
Returns the value of attribute val.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(**args) ⇒ Order
constructor
A new instance of Order.
Constructor Details
Instance Attribute Details
#order ⇒ Object (readonly)
Returns the value of attribute order.
14 15 16 |
# File 'lib/sanity/groq/order.rb', line 14 def order @order end |
#val ⇒ Object (readonly)
Returns the value of attribute val.
14 15 16 |
# File 'lib/sanity/groq/order.rb', line 14 def val @val end |
Class Method Details
.call(**args) ⇒ Object
7 8 9 |
# File 'lib/sanity/groq/order.rb', line 7 def call(**args) new(**args).call end |
Instance Method Details
#call ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/sanity/groq/order.rb', line 24 def call return unless order raise ArgumentError, "order must be hash" unless order.is_a?(Hash) order.to_a.each_with_index do |(key, sort), idx| val << " | order(#{key} #{sort})".then do |str| idx.positive? ? str : str.strip end end val end |