validated_arguments 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/validated_arguments.rb +25 -0
- data/lib/validated_arguments/version.rb +0 -0
- metadata +68 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'active_model'
|
2
|
+
|
3
|
+
class ValidatedArguments
|
4
|
+
include ActiveModel::Validations
|
5
|
+
include ActiveModel::Conversion
|
6
|
+
|
7
|
+
def ValidatedArguments.takes(args)
|
8
|
+
@args = args
|
9
|
+
attr_accessor(*args.keys)
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(args = {})
|
13
|
+
self.class.args.each { |arg_name,arg_opts|
|
14
|
+
instance_variable_set("@#{arg_name}",args[arg_name] || arg_opts[:default])
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def ValidatedArguments.args
|
19
|
+
@args
|
20
|
+
end
|
21
|
+
|
22
|
+
def persisted?
|
23
|
+
false
|
24
|
+
end
|
25
|
+
end
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: validated_arguments
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Nilesh Trivedi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-10-23 00:00:00 +05:30
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: activemodel
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
description: Use ActiveModel to validate arguments for any Ruby method
|
28
|
+
email:
|
29
|
+
- github@nileshtrivedi.com
|
30
|
+
executables: []
|
31
|
+
|
32
|
+
extensions: []
|
33
|
+
|
34
|
+
extra_rdoc_files: []
|
35
|
+
|
36
|
+
files:
|
37
|
+
- lib/validated_arguments.rb
|
38
|
+
- lib/validated_arguments/version.rb
|
39
|
+
has_rdoc: true
|
40
|
+
homepage: http://github.com/nileshtrivedi/validated_arguments
|
41
|
+
licenses: []
|
42
|
+
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "0"
|
60
|
+
requirements: []
|
61
|
+
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.5.1
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: Use ActiveModel to validate arguments for any Ruby method
|
67
|
+
test_files: []
|
68
|
+
|