Class: NextPage::Sort::SortBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/next_page/sort/sort_builder.rb

Overview

Sort Builder

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ SortBuilder

Returns a new instance of SortBuilder.



7
8
9
# File 'lib/next_page/sort/sort_builder.rb', line 7

def initialize(model)
  @model = model
end

Instance Method Details

#build(segment) ⇒ Object

TODO: support passing direction to scope



12
13
14
15
16
17
18
19
20
# File 'lib/next_page/sort/sort_builder.rb', line 12

def build(segment)
  @parser = NextPage::Sort::SegmentParser.new(segment)

  if @parser.nested?
    build_nested
  else
    build_non_nested
  end
end