resourcey 0.4.2 → 0.4.3
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e697438e59653bcf3efda698e3afd006d29db62a
|
4
|
+
data.tar.gz: 44a960c0bfab303b27fa22488bd8d3fc5023c770
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2eacaec8204b1b7bd4806d4b4872976bfe446157354a81dd317541eff58f5104ebf55a665ba5d928e80f7763eb18d54ab5c44b2b528d5c044d4a12118db41914
|
7
|
+
data.tar.gz: b97a0ad88136ef25c949404c3b595506a3fecff77ef5df96c1ee3c3bd267bf0e21ed739aa517616a3f9a58ea2bd65b3246b7bc6c4fcb9d07ea26082e809e8bc5
|
data/lib/resourcey/config.rb
CHANGED
@@ -3,21 +3,11 @@ require 'action_controller'
|
|
3
3
|
module Resourcey
|
4
4
|
class Config
|
5
5
|
attr_accessor :default_paginator
|
6
|
-
|
6
|
+
attr_accessor :controller_parent
|
7
7
|
|
8
8
|
def initialize
|
9
9
|
self.default_paginator = :paged
|
10
|
-
self.controller_parent =
|
11
|
-
end
|
12
|
-
|
13
|
-
def controller_parent=(value)
|
14
|
-
return @controller_parent = value if value.class == Class
|
15
|
-
|
16
|
-
begin
|
17
|
-
@controller_parent = value.to_s.constantize
|
18
|
-
rescue
|
19
|
-
raise Errors::RuntimeError.new("#{value} is not a valid class name")
|
20
|
-
end
|
10
|
+
self.controller_parent = 'action_controller/base'
|
21
11
|
end
|
22
12
|
end
|
23
13
|
|
data/lib/resourcey/controller.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
require 'resourcey/controller_modules'
|
2
2
|
|
3
3
|
module Resourcey
|
4
|
-
class Controller < Resourcey.config.controller_parent
|
4
|
+
class Controller < Resourcey.config.controller_parent.classify.constantize
|
5
5
|
include Resourcey::ControllerFiltering
|
6
6
|
include Resourcey::ControllerPagination
|
7
7
|
include Resourcey::ControllerModel
|
8
|
+
include Resourcey::ControllerCollectionScope
|
8
9
|
|
9
10
|
def index
|
10
|
-
render json: serialized_collection(
|
11
|
+
render json: serialized_collection(scoped_resources)
|
11
12
|
end
|
12
13
|
|
13
14
|
def show
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Resourcey
|
2
|
+
module ControllerCollectionScope
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
class_attribute :scoping_method
|
7
|
+
end
|
8
|
+
|
9
|
+
def scoped_resources
|
10
|
+
return paginated_resources if self.scoping_method.nil?
|
11
|
+
self.scoping_method.call paginated_resources
|
12
|
+
end
|
13
|
+
|
14
|
+
module ClassMethods
|
15
|
+
def collection_scope(&block)
|
16
|
+
self.scoping_method = block
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/resourcey/errors.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resourcey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- polakowski
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- lib/resourcey.rb
|
91
91
|
- lib/resourcey/config.rb
|
92
92
|
- lib/resourcey/controller.rb
|
93
|
+
- lib/resourcey/controller_collection_scope.rb
|
93
94
|
- lib/resourcey/controller_filtering.rb
|
94
95
|
- lib/resourcey/controller_model.rb
|
95
96
|
- lib/resourcey/controller_modules.rb
|