make_restful 0.1.9 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,6 +18,11 @@ module MakeRestful::ClassMethods
18
18
  end
19
19
  end
20
20
 
21
+ def paginates!(options={})
22
+ options.assert_valid_keys(:root_node)
23
+ self.pagination_options = options
24
+ end
25
+
21
26
  def resource(klass)
22
27
  self.resource_class = klass.to_s.classify.constantize
23
28
  end
@@ -53,7 +53,7 @@ module MakeRestful::Rendering
53
53
  pagination[:total_entries] = @collection.total_entries if @collection.respond_to? :total_entries
54
54
  pagination[:total_pages] = @collection.total_pages if @collection.respond_to? :total_pages
55
55
 
56
- pagination = { klass.pagination[:node] => pagination } if klass.pagination[:node]
56
+ pagination = { pagination_options[:root_node] => pagination } if pagination_options[:root_node]
57
57
 
58
58
  response = { resource_name.to_sym => response } if response.is_a?(Array)
59
59
  response.merge!(pagination)
@@ -1,3 +1,3 @@
1
1
  module MakeRestful
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
data/lib/make_restful.rb CHANGED
@@ -25,13 +25,14 @@ module MakeRestful
25
25
 
26
26
  extend ClassMethods
27
27
 
28
- class_attribute :allowed_actions, :allowed_formats, :pagination, :resource_class, instance_writer: false
28
+ class_attribute :allowed_actions, :allowed_formats, :pagination_options, :resource_class, instance_writer: false
29
29
  attr_reader :resource, :instance, :collection
30
30
 
31
+ self.pagination_options = {}
31
32
  self.allowed_actions = PermissibleActions.new(self)
32
33
  self.allowed_formats = PermissibleSet.new([:json, :jsonp, :xml])
33
34
 
34
- private :klass, :allowed_actions, :allowed_formats, :pagination, :resource_class, :allow_method?, :allow_format?, :allowed_actions?, :allowed_formats?, :pagination?, :resource_class?
35
+ private :klass, :allowed_actions, :allowed_formats, :pagination_options, :resource_class, :allow_method?, :allow_format?, :allowed_actions?, :allowed_formats?, :pagination_options?, :resource_class?
35
36
  helper_method :resource, :instance, :collection
36
37
 
37
38
  resource name.underscore.gsub(/(.*)_controller/,'\1').singularize rescue nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: make_restful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-20 00:00:00.000000000 Z
12
+ date: 2012-11-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport