class Test < ActiveRecord::Model
scope :complicated, ComplicatedScope
class ComplicatedScope
def self.call(*args) # in new syntax use (...)
new(*args).call
end
def initialize(arg_1) # provide scope arguments
@arg_1 = arg_1
end
def call
module_parent
.joins("complicated JOIN querry")
.where("complicated where ?", @arg_1)
.merge("some merging")
end
delegate :module_parent, to: :class
end
end
Test.complcated("arg_1")