params_for 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +5 -5
- data/lib/{params_validator → params_for}/base.rb +1 -1
- data/lib/{params_validator/connectors/params_for.rb → params_for/connectors/glue.rb} +3 -3
- data/lib/params_for/version.rb +3 -0
- data/lib/params_for.rb +12 -0
- data/params_for.gemspec +2 -2
- data/spec/{params_validator → params_for}/base_spec.rb +3 -3
- data/spec/shared/support/dummy_controller.rb +3 -3
- data/spec/spec_helper.rb +1 -1
- metadata +9 -9
- data/lib/params_validator/version.rb +0 -3
- data/lib/params_validator.rb +0 -12
- /data/spec/{params_validator/connectors/params_for_spec.rb → params_for/connectors/glue_spec.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8cef79cc5641a6860e4df2ad3adb4ad2fd1fa42
|
4
|
+
data.tar.gz: 240969f6a63bd4e3a9a7376d0ab7e2458dcc6ae5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 122bea292a672b722ad98fabdfe7d59cf48e9e8f463334d888db18b434840bdeb4623115903c9340cb679499832540f12d695e282cfbf983a494698a9f7fc6ce
|
7
|
+
data.tar.gz: 70e50ac65ff040047f015a73ab05557a4f1938887b2b15611e09b0cf670da61795d7b0a0a2e18e7842214af9e5b19fbd07ed6d9778a7ea3dcbe60d11fd57063c
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -16,7 +16,7 @@ And then execute:
|
|
16
16
|
|
17
17
|
Or install it yourself as:
|
18
18
|
|
19
|
-
$ gem install
|
19
|
+
$ gem install params_for
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
@@ -27,7 +27,7 @@ In your controller:
|
|
27
27
|
# app/controllers/fancy_controller.rb
|
28
28
|
|
29
29
|
class Fancycontroller < ApplicationController
|
30
|
-
include
|
30
|
+
include ParamsFor::Connectors::Glue
|
31
31
|
|
32
32
|
params_for :fancy, only: [:create]
|
33
33
|
|
@@ -48,7 +48,7 @@ Or you can play with it yourself
|
|
48
48
|
# app/controllers/fancy_controller.rb
|
49
49
|
|
50
50
|
class Fancycontroller < ApplicationController
|
51
|
-
include
|
51
|
+
include ParamsFor::Connectors::Glue
|
52
52
|
|
53
53
|
# Creates a Fancy object by checking and validating params
|
54
54
|
# before that
|
@@ -71,7 +71,7 @@ class Fancycontroller < ApplicationController
|
|
71
71
|
end
|
72
72
|
```
|
73
73
|
|
74
|
-
Some place in your application ( suggested `app/validators/
|
74
|
+
Some place in your application ( suggested `app/validators/params_for/` )
|
75
75
|
|
76
76
|
```Ruby
|
77
77
|
# app/validators/param_validator/fancy.rb
|
@@ -86,7 +86,7 @@ Some place in your application ( suggested `app/validators/params_validator/` )
|
|
86
86
|
|
87
87
|
## Contributing
|
88
88
|
|
89
|
-
1. Fork it ( https://github.com/[my-github-username]/
|
89
|
+
1. Fork it ( https://github.com/[my-github-username]/params_for/fork )
|
90
90
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
91
91
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
92
92
|
4. Push to the branch (`git push origin my-new-feature`)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'active_support/concern'
|
2
2
|
|
3
|
-
module
|
3
|
+
module ParamsFor
|
4
4
|
module Connectors
|
5
|
-
module
|
5
|
+
module Glue
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
module ClassMethods
|
@@ -38,7 +38,7 @@ module ParamsValidator
|
|
38
38
|
if options[:class]
|
39
39
|
validator_klass = options[:class]
|
40
40
|
else
|
41
|
-
validator_name = "
|
41
|
+
validator_name = "ParamsFor::#{name.to_s.classify}"
|
42
42
|
validator_klass = validator_name.constantize
|
43
43
|
end
|
44
44
|
|
data/lib/params_for.rb
ADDED
data/params_for.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require '
|
4
|
+
require 'params_for/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "params_for"
|
8
|
-
spec.version =
|
8
|
+
spec.version = ParamsFor::VERSION
|
9
9
|
spec.authors = ["andresbravog"]
|
10
10
|
spec.email = ["andresbravog@gmail.com"]
|
11
11
|
spec.summary = %q{Params Validatior for controllers using active_model validations.}
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe ParamsFor::Base do
|
4
4
|
|
5
5
|
let(:validator_klass) do
|
6
6
|
unless defined?(DummyValidator)
|
7
|
-
class DummyValidator <
|
7
|
+
class DummyValidator < ParamsFor::Base
|
8
8
|
attr_accessor :id, :name, :type
|
9
9
|
|
10
10
|
validates :type, inclusion: { in: %w{task project}, allow_nil: true }
|
@@ -43,7 +43,7 @@ describe ParamsValidator::Base do
|
|
43
43
|
describe 'attributes_hash' do
|
44
44
|
let(:validator_klass_with_modified_accessor) do
|
45
45
|
unless defined?(NewDummyValidator)
|
46
|
-
class NewDummyValidator <
|
46
|
+
class NewDummyValidator < ParamsFor::Base
|
47
47
|
attr_accessor :id, :name
|
48
48
|
|
49
49
|
def id
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'action_controller'
|
2
|
-
require '
|
2
|
+
require 'params_for'
|
3
3
|
require 'ostruct'
|
4
4
|
|
5
5
|
module Rails
|
@@ -47,7 +47,7 @@ Rails.application.routes.draw do
|
|
47
47
|
resources :dummy, only: [:index]
|
48
48
|
end
|
49
49
|
|
50
|
-
class
|
50
|
+
class ParamsFor::Dummy < ParamsFor::Base
|
51
51
|
attr_accessor :id, :name
|
52
52
|
|
53
53
|
validates :id, presence: true
|
@@ -56,7 +56,7 @@ end
|
|
56
56
|
|
57
57
|
class DummyController < ActionController::Base
|
58
58
|
include Rails.application.routes.url_helpers
|
59
|
-
include
|
59
|
+
include ParamsFor::Connectors::Glue
|
60
60
|
|
61
61
|
params_for :dummy
|
62
62
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: params_for
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- andresbravog
|
@@ -136,13 +136,13 @@ files:
|
|
136
136
|
- LICENSE.txt
|
137
137
|
- README.md
|
138
138
|
- Rakefile
|
139
|
-
- lib/
|
140
|
-
- lib/
|
141
|
-
- lib/
|
142
|
-
- lib/
|
139
|
+
- lib/params_for.rb
|
140
|
+
- lib/params_for/base.rb
|
141
|
+
- lib/params_for/connectors/glue.rb
|
142
|
+
- lib/params_for/version.rb
|
143
143
|
- params_for.gemspec
|
144
|
-
- spec/
|
145
|
-
- spec/
|
144
|
+
- spec/params_for/base_spec.rb
|
145
|
+
- spec/params_for/connectors/glue_spec.rb
|
146
146
|
- spec/shared/support/dummy_controller.rb
|
147
147
|
- spec/spec_helper.rb
|
148
148
|
homepage: https://github.com/andresbravog/params_for
|
@@ -170,7 +170,7 @@ signing_key:
|
|
170
170
|
specification_version: 4
|
171
171
|
summary: Params Validatior for controllers using active_model validations.
|
172
172
|
test_files:
|
173
|
-
- spec/
|
174
|
-
- spec/
|
173
|
+
- spec/params_for/base_spec.rb
|
174
|
+
- spec/params_for/connectors/glue_spec.rb
|
175
175
|
- spec/shared/support/dummy_controller.rb
|
176
176
|
- spec/spec_helper.rb
|
data/lib/params_validator.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'active_support/hash_with_indifferent_access'
|
2
|
-
require 'active_model'
|
3
|
-
require 'params_validator/version'
|
4
|
-
|
5
|
-
module ParamsValidator
|
6
|
-
|
7
|
-
autoload :Base, 'params_validator/base'
|
8
|
-
|
9
|
-
module Connectors
|
10
|
-
autoload :ParamsFor, 'params_validator/connectors/params_for'
|
11
|
-
end
|
12
|
-
end
|
/data/spec/{params_validator/connectors/params_for_spec.rb → params_for/connectors/glue_spec.rb}
RENAMED
File without changes
|