restpack-resource 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- restpack-resource (0.1.4)
4
+ restpack-resource (0.1.6)
5
5
  activesupport (~> 3.2.11)
6
6
  datamapper (~> 1.2.0)
7
7
  dm-pager (~> 1.1.0)
@@ -7,7 +7,7 @@ module RestPack
7
7
  @resource_filterable_by || []
8
8
  end
9
9
  def resource_filterable_by=(columns)
10
- @resource_filterable_by = columns
10
+ @resource_filterable_by = columns.uniq
11
11
  end
12
12
  def resource_can_filter_by(*columns)
13
13
  self.resource_filterable_by += columns
@@ -7,7 +7,7 @@ module RestPack
7
7
  @resource_includable_associations || []
8
8
  end
9
9
  def resource_includable_associations=(associations)
10
- @resource_includable_associations = associations
10
+ @resource_includable_associations = associations.uniq
11
11
  end
12
12
  def resource_can_include(*associations)
13
13
  self.resource_includable_associations += associations
@@ -7,7 +7,7 @@ module RestPack
7
7
  @resource_sortable_by || []
8
8
  end
9
9
  def resource_sortable_by=(columns)
10
- @resource_sortable_by = columns
10
+ @resource_sortable_by = columns.uniq
11
11
  end
12
12
  def resource_can_sort_by(*columns)
13
13
  self.resource_sortable_by += columns
@@ -4,7 +4,6 @@ module RestPack
4
4
  module Service
5
5
 
6
6
  def paged_resource(klass, params, options = {})
7
- p "1 Params: #{params}"
8
7
  options[:page] ||= params['page'].to_i if params['page']
9
8
  options[:includes] ||= extract_includes_from_params(params) unless params['includes'].nil?
10
9
  options[:sort_by] ||= params['sort_by'].to_sym if params['sort_by']
@@ -12,7 +11,7 @@ module RestPack
12
11
 
13
12
  filters = extract_filters_from_params(klass, params)
14
13
  options[:filters] ||= filters unless filters.empty?
15
- p "3 Options: #{options}"
14
+
16
15
  klass.paged_resource(options)
17
16
  end
18
17
 
@@ -27,7 +26,6 @@ module RestPack
27
26
 
28
27
  def extract_filters_from_params(klass, params)
29
28
  extracted = params.with_indifferent_access.extract!(*klass.resource_filterable_by)
30
- p "2. EXTRA: #{extracted}"
31
29
  extracted.delete_if { |k, v| v.nil? }
32
30
  end
33
31
 
@@ -1,5 +1,5 @@
1
1
  module RestPack
2
2
  module Resource
3
- VERSION = "0.1.6"
3
+ VERSION = "0.1.7"
4
4
  end
5
5
  end
@@ -19,7 +19,7 @@ describe RestPack::Resource do
19
19
  MyModel.resource_includable_associations.length == 0
20
20
  class MyModel
21
21
  resource_can_include :association1
22
- resource_can_include :association2, :association3
22
+ resource_can_include :association2, :association3, :association3
23
23
  end
24
24
  MyModel.resource_includable_associations.should == [:association1, :association2, :association3]
25
25
  end
@@ -31,6 +31,7 @@ describe RestPack::Resource do
31
31
  class MyModel
32
32
  resource_can_filter_by :id
33
33
  resource_can_filter_by :name, :age
34
+ resource_can_filter_by :name, :age
34
35
  end
35
36
  MyModel.resource_filterable_by.should == [:id, :name, :age]
36
37
  end
@@ -41,7 +42,7 @@ describe RestPack::Resource do
41
42
  MyModel.resource_sortable_by.length == 0
42
43
  class MyModel
43
44
  resource_can_sort_by :id
44
- resource_can_sort_by :name, :age
45
+ resource_can_sort_by :name, :age, :id
45
46
  end
46
47
  MyModel.resource_sortable_by.should == [:id, :name, :age]
47
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restpack-resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: