Module: RestPack::Resource::Filterable

Defined in:
lib/restpack-resource/resource/filterable.rb

Instance Method Summary collapse

Instance Method Details

#resource_can_filter_by(*columns) ⇒ Object



12
13
14
# File 'lib/restpack-resource/resource/filterable.rb', line 12

def resource_can_filter_by(*columns)
  self.resource_filterable_by += columns
end

#resource_filterable_byObject



6
7
8
# File 'lib/restpack-resource/resource/filterable.rb', line 6

def resource_filterable_by
  @resource_filterable_by || []
end

#resource_filterable_by=(columns) ⇒ Object



9
10
11
# File 'lib/restpack-resource/resource/filterable.rb', line 9

def resource_filterable_by=(columns)
  @resource_filterable_by = columns.uniq
end

#resource_validate_filters!(filters) ⇒ Object



15
16
17
18
19
20
# File 'lib/restpack-resource/resource/filterable.rb', line 15

def resource_validate_filters!(filters)
  return unless filters
  filters.keys.each do |filter|
    raise InvalidFilter.new unless self.resource_filterable_by.include?(filter)
  end
end