Module: RestPack::Resource::Sortable
- Defined in:
- lib/restpack-resource/resource/sortable.rb
Instance Method Summary collapse
- #resource_can_sort_by(*columns) ⇒ Object
- #resource_sortable_by ⇒ Object
- #resource_sortable_by=(columns) ⇒ Object
- #resource_validate_sort_by!(sort_by) ⇒ Object
Instance Method Details
#resource_can_sort_by(*columns) ⇒ Object
12 13 14 |
# File 'lib/restpack-resource/resource/sortable.rb', line 12 def resource_can_sort_by(*columns) self.resource_sortable_by += columns end |
#resource_sortable_by ⇒ Object
6 7 8 |
# File 'lib/restpack-resource/resource/sortable.rb', line 6 def resource_sortable_by @resource_sortable_by || [] end |
#resource_sortable_by=(columns) ⇒ Object
9 10 11 |
# File 'lib/restpack-resource/resource/sortable.rb', line 9 def resource_sortable_by=(columns) @resource_sortable_by = columns.uniq end |
#resource_validate_sort_by!(sort_by) ⇒ Object
15 16 17 |
# File 'lib/restpack-resource/resource/sortable.rb', line 15 def resource_validate_sort_by!(sort_by) raise InvalidSortBy.new unless sort_by.nil? || self.resource_sortable_by.include?(sort_by) end |