ensure_param_exists 0.0.1
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.
- data/lib/ensure_param_exists.rb +11 -0
- metadata +48 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
module EnsureParamExists
|
2
|
+
def define_ensure_param_exists_for(*expected_params)
|
3
|
+
expected_params.each do |expected_param|
|
4
|
+
method_name = "ensure_#{expected_param}_exists"
|
5
|
+
define_method(method_name) do
|
6
|
+
return unless params[expected_param.to_sym].blank?
|
7
|
+
render json: { success: false, message: "missing #{expected_param.to_s} parameter" }, status: 422
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ensure_param_exists
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Gavin Miller
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-10-01 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: A quick mixin that lets you quickly define methods to ensure a parameter
|
15
|
+
exists on a request
|
16
|
+
email: gavin@petrofeed.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/ensure_param_exists.rb
|
22
|
+
homepage: ''
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 1.8.23
|
44
|
+
signing_key:
|
45
|
+
specification_version: 3
|
46
|
+
summary: Simple mixin to generate ensure_param_exist methods
|
47
|
+
test_files: []
|
48
|
+
has_rdoc:
|