Class: Sortiri::Parser
- Inherits:
-
Object
- Object
- Sortiri::Parser
- Defined in:
- lib/sortiri/parser.rb
Constant Summary collapse
- DELIMITER =
','
Instance Attribute Summary collapse
-
#sort_string ⇒ Object
readonly
Returns the value of attribute sort_string.
-
#sortable_columns ⇒ Object
readonly
Returns the value of attribute sortable_columns.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(sortable_columns:, sort_string:) ⇒ Parser
constructor
A new instance of Parser.
- #whitelisted_columns ⇒ Object
Constructor Details
#initialize(sortable_columns:, sort_string:) ⇒ Parser
Returns a new instance of Parser.
9 10 11 12 |
# File 'lib/sortiri/parser.rb', line 9 def initialize(sortable_columns:, sort_string:) @sortable_columns = sortable_columns # Array of Sortiri::ActiveRecord::Column @sort_string = sort_string end |
Instance Attribute Details
#sort_string ⇒ Object (readonly)
Returns the value of attribute sort_string.
7 8 9 |
# File 'lib/sortiri/parser.rb', line 7 def sort_string @sort_string end |
#sortable_columns ⇒ Object (readonly)
Returns the value of attribute sortable_columns.
7 8 9 |
# File 'lib/sortiri/parser.rb', line 7 def sortable_columns @sortable_columns end |
Class Method Details
Instance Method Details
#whitelisted_columns ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/sortiri/parser.rb', line 14 def whitelisted_columns columns = self.class.parse(sort_string: sort_string) columns.select do |column| sortable_columns.any? { |c| c.matches_with?(column) } end end |