lib/querifier/queries/order.rb in querifier-0.1.1 vs lib/querifier/queries/order.rb in querifier-0.2.2
- old
+ new
@@ -59,16 +59,26 @@
module ClassMethods
@@order_attributes = []
@@default_sort = { id: :asc }
def order_attributes(*value)
- return @@order_attributes = [*value] if value.any?
- @@order_attributes
+ return class_variable_set :@@order_attributes, [*value] if value.any?
+ begin
+ class_variable_get :@@order_attributes
+ rescue NameError
+ class_variable_set :@@order_attributes, []
+ class_variable_get :@@order_attributes
+ end
end
def default_sort(value = nil)
- return @@default_sort = value if value
- @@default_sort
+ return class_variable_set :@@default_sort, value if value
+ begin
+ class_variable_get :@@default_sort
+ rescue NameError
+ class_variable_set :@@default_sort, { id: :asc }
+ class_variable_get :@@default_sort
+ end
end
end
end
end
end