Module: Util::Params
- Defined in:
- lib/util/params.rb,
lib/util/params/error.rb,
lib/util/params/params.rb,
lib/util/params/version.rb
Defined Under Namespace
Modules: Type
Classes: Error
Constant Summary
collapse
- VERSION =
"0.2.14"
Instance Method Summary
collapse
Instance Method Details
#get_array_params(key, options = {}) ⇒ Object
63
64
65
66
|
# File 'lib/util/params/params.rb', line 63
def get_array_params key, options={}
base = {key: key, type: Type::ARRAY, null: true}
get_params base.merge(options)
end
|
#get_bool_params(key, options = {}) ⇒ Object
58
59
60
61
|
# File 'lib/util/params/params.rb', line 58
def get_bool_params key, options={}
base = {key: key, type: Type::BOOLEAN, null: true}
get_params base.merge(options)
end
|
#get_file_params(key, options = {}) ⇒ Object
53
54
55
56
|
# File 'lib/util/params/params.rb', line 53
def get_file_params key, options={}
base = {key: key, type: Type::FILE, null: true}
get_params base.merge(options)
end
|
#get_float_params(key, options = {}) ⇒ Object
48
49
50
51
|
# File 'lib/util/params/params.rb', line 48
def get_float_params key, options={}
base = {key: key, type: Type::FLOAT, null: true}
get_params base.merge(options)
end
|
#get_int_params(key, options = {}) ⇒ Object
38
39
40
41
|
# File 'lib/util/params/params.rb', line 38
def get_int_params key, options={}
base = {key: key, type: Type::INTEGER, null: true}
get_params base.merge(options)
end
|
#get_object_params(key, options = {}) ⇒ Object
68
69
70
71
|
# File 'lib/util/params/params.rb', line 68
def get_object_params key, options={}
base = {key: key, type: Type::OBJECT, null: true}
get_params base.merge(options)
end
|
#get_params(options) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/util/params/params.rb', line 23
def get_params options
options = options.deep_symbolize_keys
key = options[:key]
val = _load_val params.permit!.to_h, key, options[:default], options[:require]
unless options[:null]
_push_error "*[#{key.to_s}] == nil" if val.nil?
end
return nil if val.nil?
_validate key, options[:type], val, options
end
|
#get_params_error ⇒ Object
79
80
81
|
# File 'lib/util/params/params.rb', line 79
def get_params_error
@errors.join ', '
end
|
#get_str_params(key, options = {}) ⇒ Object
43
44
45
46
|
# File 'lib/util/params/params.rb', line 43
def get_str_params key, options={}
base = {key: key, type: Type::STRING, null: true}
get_params base.merge(options)
end
|
#has_params_error? ⇒ Boolean
75
76
77
|
# File 'lib/util/params/params.rb', line 75
def has_params_error?
@is_error
end
|
#initialize ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/util/params/params.rb', line 5
def initialize
super
@is_error = false
@errors = []
end
|