class Siphon::Base
¶ ↑
Base
¶ ↑
use : Handles the ActiveRelation on which
scopes from a **FormObject** will be applied
e.g : Siphon::Base.new(Book.published).scope(BookForm.new(params[:q]
))
Attributes
relation[RW]
Public Class Methods
new(relation)
click to toggle source
Siphon.new(Book.scoped)
# File lib/siphon/base.rb, line 15 def initialize(relation) @relation = relation end
Public Instance Methods
scope(formobject)
click to toggle source
# File lib/siphon/base.rb, line 19 def scope(formobject) scopes_hash = Siphon::Adapter.new(formobject).call scopes_hash.each do |meth, arg| self.relation = if arg.is_a?(Array) arg.any? ? relation.send(meth, *arg) : relation elsif arg.nil? relation.send(meth) else relation.send(meth, arg) end end relation end