module JSONAPI::Resources::SortableFieldsDsl
def inherited_sort_only_fields
def inherited_sort_only_fields parent_sort_fields = superclass.permitted_sortable_fields parent_attributes = superclass.permitted_attributes parent_sort_fields - parent_attributes end
def permitted_sortable_fields
def permitted_sortable_fields sort_fields = @sortable_fields || [] sort_fields = inherited_sort_only_fields + sort_fields if should_inherit_sortable_fields? (permitted_attributes + sort_fields).uniq end
def should_inherit_sortable_fields?
def should_inherit_sortable_fields? !instance_variable_defined?(:@sortable_fields) && !instance_variable_defined?(:@attributes) && superclass != JSONAPI::Resource && superclass.respond_to?(:permitted_sortable_fields) end
def sortable_fields(*field_names)
def sortable_fields(*field_names) @sortable_fields ||= [] @sortable_fields.concat(field_names.map(&:to_sym)) @sortable_fields.uniq! end