Class: SimpleParams::NestedParams
- Inherits:
-
Params
- Object
- Params
- SimpleParams::NestedParams
show all
- Defined in:
- lib/simple_params/nested_params.rb
Constant Summary
HasTypedParams::TYPES
Instance Attribute Summary
Attributes inherited from Params
#original_params
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Params
api_pie_documentation, #errors, model_name, nested_array, nested_arrays, nested_classes, nested_hash, nested_hashes, param, #to_hash
#valid?, #validate!
Constructor Details
#initialize(params = {}, parent = nil) ⇒ NestedParams
Returns a new instance of NestedParams.
42
43
44
45
|
# File 'lib/simple_params/nested_params.rb', line 42
def initialize(params={}, parent = nil)
@parent = parent
super(params)
end
|
Class Method Details
.array? ⇒ Boolean
8
9
10
|
# File 'lib/simple_params/nested_params.rb', line 8
def array?
type.to_sym == :array
end
|
.define_new_array_class(parent, name, options, &block) ⇒ Object
25
26
27
28
|
# File 'lib/simple_params/nested_params.rb', line 25
def define_new_array_class(parent, name, options, &block)
options = options.merge(type: :array)
define_new_class(parent, name, options, &block)
end
|
.define_new_hash_class(parent, name, options, &block) ⇒ Object
20
21
22
23
|
# File 'lib/simple_params/nested_params.rb', line 20
def define_new_hash_class(parent, name, options, &block)
options = options.merge(type: :hash)
define_new_class(parent, name, options, &block)
end
|
.hash? ⇒ Boolean
12
13
14
|
# File 'lib/simple_params/nested_params.rb', line 12
def hash?
type.to_sym == :hash
end
|
.type ⇒ Object
4
5
6
|
# File 'lib/simple_params/nested_params.rb', line 4
def type
options[:type]
end
|
.with_ids? ⇒ Boolean
16
17
18
|
# File 'lib/simple_params/nested_params.rb', line 16
def with_ids?
!!options[:with_ids]
end
|
Instance Method Details
#id ⇒ Object
47
48
49
|
# File 'lib/simple_params/nested_params.rb', line 47
def id
@id
end
|
#set_accessors(params = {}) ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'lib/simple_params/nested_params.rb', line 51
def set_accessors(params={})
if class_has_ids?
@id = params.keys.first
params = params.values.first || {}
end
super(params)
end
|