fast_crud 0.1.14 → 0.1.17

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: 56c911778944fa8511f3610355c282f1b013b75c
4
- data.tar.gz: 73f4042dbf135edeab864635bcb955eb21082a57
3
+ metadata.gz: 4c383130a28b1ab4cb4dc2d0135a8a74de4939d6
4
+ data.tar.gz: b3e2fc8319845c6894d9d7885e0d891851c06e70
5
5
  SHA512:
6
- metadata.gz: 8a2d1dbfeaf50644a005045e187c63db94e31df8d5125708ad15ce76067d5a4e3477932caacc1a6e8081a3cc41dccb666b5e523b05b2ecc849e5b0468314a173
7
- data.tar.gz: 6e65990d29bff24ebd1bcbe6bd70c694cf7ec6d4b11833a8ed1b6f3aa4dcb63b97c7958476d9e52c5058a34f42ff20181851e68ba4b6626afa5eb29b0818a6d4
6
+ metadata.gz: dc192e8c2664e0c9a9e9dbb5be540167e83f5bf87dd3d38afc74c21c9e427d3618ac95d64905542073c47653df46d69e4f60bb89a2b834be1c32194edb2c74e1
7
+ data.tar.gz: 94ee1db540819b94db6035b9c19a006bc5224f3cae98dcd36d5650a1f34d21488f3420e95f6ab9475410fd6adeb3da6e476bca9810bd4bfe05a2ea415e6618ae
@@ -5,7 +5,7 @@ require 'fast_crud/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "fast_crud"
8
- spec.version = '0.1.14'
8
+ spec.version = '0.1.17'
9
9
  spec.authors = ["lou"]
10
10
  spec.email = ["louguenier@gmail.com"]
11
11
 
@@ -3,7 +3,11 @@ require "fast_crud/version"
3
3
  module FastCrud
4
4
  class FastCrud < ActionController::Base
5
5
  def index
6
- @collection = model.all
6
+ if request.filtered_parameters.has_rkey? /_id/
7
+ @collection = nested_collection
8
+ else
9
+ @collection = model.all
10
+ end
7
11
  end
8
12
 
9
13
  def show
@@ -64,5 +68,17 @@ module FastCrud
64
68
  def model
65
69
  controller_name.classify.constantize
66
70
  end
71
+
72
+ def nested_collection
73
+ path = request.fullpath.split("/").reject {|a| a.empty?}.last(3)
74
+ path.first.classify.constantize.find(path[1]).send(path.last)
75
+ end
76
+ end
77
+ end
78
+
79
+ class Hash
80
+ def has_rkey?(search)
81
+ search = Regexp.new(search.to_s) unless search.is_a?(Regexp)
82
+ !!keys.detect{ |key| key =~ search }
67
83
  end
68
84
  end
@@ -1,3 +1,3 @@
1
1
  module FastCrud
2
- VERSION = "0.1.14"
2
+ VERSION = "0.1.17"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_crud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - lou
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-24 00:00:00.000000000 Z
11
+ date: 2017-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler