simple_form 2.1.3 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of simple_form might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -51
- data/README.md +195 -161
- data/lib/generators/simple_form/install_generator.rb +4 -4
- data/lib/generators/simple_form/templates/README +2 -2
- data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +16 -13
- data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +16 -16
- data/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb +3 -3
- data/lib/simple_form/action_view_extensions/builder.rb +1 -320
- data/lib/simple_form/action_view_extensions/builder.rb.orig +247 -0
- data/lib/simple_form/action_view_extensions/form_helper.rb +2 -9
- data/lib/simple_form/components/errors.rb +1 -7
- data/lib/simple_form/components/hints.rb +2 -7
- data/lib/simple_form/components/html5.rb +5 -2
- data/lib/simple_form/components/labels.rb +4 -4
- data/lib/simple_form/components/maxlength.rb +1 -8
- data/lib/simple_form/components/pattern.rb +2 -2
- data/lib/simple_form/components.rb +1 -1
- data/lib/simple_form/error_notification.rb +2 -2
- data/lib/simple_form/form_builder.rb +154 -50
- data/lib/simple_form/form_builder.rb.orig +486 -0
- data/lib/simple_form/helpers.rb +1 -1
- data/lib/simple_form/inputs/base.rb +7 -10
- data/lib/simple_form/inputs/block_input.rb +1 -1
- data/lib/simple_form/inputs/boolean_input.rb +6 -5
- data/lib/simple_form/inputs/collection_input.rb +7 -7
- data/lib/simple_form/inputs/date_time_input.rb +1 -1
- data/lib/simple_form/inputs/numeric_input.rb +0 -6
- data/lib/simple_form/inputs/password_input.rb +0 -1
- data/lib/simple_form/inputs/string_input.rb +0 -1
- data/lib/simple_form/railtie.rb +7 -0
- data/lib/simple_form/tags.rb +62 -0
- data/lib/simple_form/version.rb +1 -1
- data/lib/simple_form/version.rb.orig +7 -0
- data/lib/simple_form/wrappers/builder.rb +5 -29
- data/lib/simple_form/wrappers/many.rb +1 -1
- data/lib/simple_form/wrappers/root.rb +1 -1
- data/lib/simple_form/wrappers.rb +1 -1
- data/lib/simple_form.rb +43 -47
- data/test/action_view_extensions/builder_test.rb +78 -99
- data/test/action_view_extensions/form_helper_test.rb +25 -16
- data/test/components/label_test.rb +46 -46
- data/test/form_builder/association_test.rb +47 -29
- data/test/form_builder/button_test.rb +4 -4
- data/test/form_builder/error_notification_test.rb +8 -8
- data/test/form_builder/error_test.rb +18 -65
- data/test/form_builder/general_test.rb +62 -63
- data/test/form_builder/hint_test.rb +23 -29
- data/test/form_builder/input_field_test.rb +29 -12
- data/test/form_builder/label_test.rb +7 -17
- data/test/form_builder/wrapper_test.rb +21 -21
- data/test/inputs/boolean_input_test.rb +24 -24
- data/test/inputs/collection_check_boxes_input_test.rb +66 -55
- data/test/inputs/collection_radio_buttons_input_test.rb +81 -79
- data/test/inputs/collection_select_input_test.rb +76 -51
- data/test/inputs/datetime_input_test.rb +17 -11
- data/test/inputs/disabled_test.rb +10 -10
- data/test/inputs/discovery_test.rb +4 -4
- data/test/inputs/file_input_test.rb +1 -1
- data/test/inputs/general_test.rb +28 -12
- data/test/inputs/grouped_collection_select_input_test.rb +33 -20
- data/test/inputs/hidden_input_test.rb +3 -2
- data/test/inputs/numeric_input_test.rb +3 -3
- data/test/inputs/priority_input_test.rb +9 -3
- data/test/inputs/readonly_test.rb +12 -12
- data/test/inputs/required_test.rb +5 -5
- data/test/inputs/string_input_test.rb +15 -25
- data/test/inputs/text_input_test.rb +1 -1
- data/test/support/misc_helpers.rb +46 -24
- data/test/support/mock_controller.rb +6 -6
- data/test/support/models.rb +77 -62
- data/test/test_helper.rb +17 -34
- metadata +39 -22
- data/lib/simple_form/core_ext/hash.rb +0 -16
data/test/support/models.rb
CHANGED
@@ -1,27 +1,38 @@
|
|
1
1
|
Association = Struct.new(:klass, :name, :macro, :options)
|
2
2
|
|
3
|
-
|
3
|
+
Column = Struct.new(:name, :type, :limit) do
|
4
4
|
# Returns +true+ if the column is either of type integer, float or decimal.
|
5
5
|
def number?
|
6
6
|
type == :integer || type == :float || type == :decimal
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
Relation = Struct.new(:all) do
|
11
|
+
def where(conditions = nil)
|
12
|
+
self.class.new conditions ? all.first : all
|
13
|
+
end
|
14
|
+
|
15
|
+
def order(conditions = nil)
|
16
|
+
self.class.new conditions ? all.last : all
|
17
|
+
end
|
18
|
+
|
19
|
+
alias_method :to_a, :all
|
20
|
+
end
|
21
|
+
|
22
|
+
Company = Struct.new(:id, :name) do
|
11
23
|
extend ActiveModel::Naming
|
12
24
|
include ActiveModel::Conversion
|
13
25
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
all
|
26
|
+
class << self
|
27
|
+
delegate :order, :where, to: :_relation
|
28
|
+
end
|
29
|
+
|
30
|
+
def self._relation
|
31
|
+
Relation.new(all)
|
21
32
|
end
|
22
33
|
|
23
|
-
def self.
|
24
|
-
(
|
34
|
+
def self.all
|
35
|
+
(1..3).map { |i| new(i, "#{name} #{i}") }
|
25
36
|
end
|
26
37
|
|
27
38
|
def persisted?
|
@@ -29,14 +40,9 @@ class Company < Struct.new(:id, :name)
|
|
29
40
|
end
|
30
41
|
end
|
31
42
|
|
32
|
-
class Tag < Company
|
33
|
-
def self.all(options={})
|
34
|
-
(1..3).map{|i| Tag.new(i, "Tag #{i}")}
|
35
|
-
end
|
36
|
-
end
|
43
|
+
class Tag < Company; end
|
37
44
|
|
38
|
-
|
39
|
-
end
|
45
|
+
TagGroup = Struct.new(:id, :name, :tags)
|
40
46
|
|
41
47
|
class User
|
42
48
|
extend ActiveModel::Naming
|
@@ -46,7 +52,19 @@ class User
|
|
46
52
|
:description, :created_at, :updated_at, :credit_limit, :password, :url,
|
47
53
|
:delivery_time, :born_at, :special_company_id, :country, :tags, :tag_ids,
|
48
54
|
:avatar, :home_picture, :email, :status, :residence_country, :phone_number,
|
49
|
-
:post_count, :lock_version, :amount, :attempts, :action, :credit_card, :gender
|
55
|
+
:post_count, :lock_version, :amount, :attempts, :action, :credit_card, :gender,
|
56
|
+
:extra_special_company_id
|
57
|
+
|
58
|
+
def self.build(extra_attributes = {})
|
59
|
+
attributes = {
|
60
|
+
id: 1,
|
61
|
+
name: 'New in SimpleForm!',
|
62
|
+
description: 'Hello!',
|
63
|
+
created_at: Time.now
|
64
|
+
}.merge! extra_attributes
|
65
|
+
|
66
|
+
new attributes
|
67
|
+
end
|
50
68
|
|
51
69
|
def initialize(options={})
|
52
70
|
@new_record = false
|
@@ -112,7 +130,9 @@ class User
|
|
112
130
|
when :first_company
|
113
131
|
Association.new(Company, association, :has_one, {})
|
114
132
|
when :special_company
|
115
|
-
Association.new(Company, association, :belongs_to, { :
|
133
|
+
Association.new(Company, association, :belongs_to, { conditions: { id: 1 } })
|
134
|
+
when :extra_special_company
|
135
|
+
Association.new(Company, association, :belongs_to, { conditions: proc { { id: 1 } } })
|
116
136
|
end
|
117
137
|
end
|
118
138
|
|
@@ -120,11 +140,11 @@ class User
|
|
120
140
|
@errors ||= begin
|
121
141
|
hash = Hash.new { |h,k| h[k] = [] }
|
122
142
|
hash.merge!(
|
123
|
-
:
|
124
|
-
:
|
125
|
-
:
|
126
|
-
:
|
127
|
-
:
|
143
|
+
name: ["can't be blank"],
|
144
|
+
description: ["must be longer than 15 characters"],
|
145
|
+
age: ["is not a number", "must be greater than 18"],
|
146
|
+
company: ["company must be present"],
|
147
|
+
company_id: ["must be valid"]
|
128
148
|
)
|
129
149
|
end
|
130
150
|
end
|
@@ -136,31 +156,31 @@ end
|
|
136
156
|
|
137
157
|
class ValidatingUser < User
|
138
158
|
include ActiveModel::Validations
|
139
|
-
validates :name, :
|
140
|
-
validates :company, :
|
141
|
-
validates :age, :
|
142
|
-
validates :amount, :
|
159
|
+
validates :name, presence: true
|
160
|
+
validates :company, presence: true
|
161
|
+
validates :age, presence: true, if: Proc.new { |user| user.name }
|
162
|
+
validates :amount, presence: true, unless: Proc.new { |user| user.age }
|
143
163
|
|
144
|
-
validates :action, :
|
145
|
-
validates :credit_limit, :
|
146
|
-
validates :phone_number, :
|
164
|
+
validates :action, presence: true, on: :create
|
165
|
+
validates :credit_limit, presence: true, on: :save
|
166
|
+
validates :phone_number, presence: true, on: :update
|
147
167
|
|
148
168
|
validates_numericality_of :age,
|
149
|
-
:
|
150
|
-
:
|
151
|
-
:
|
169
|
+
greater_than_or_equal_to: 18,
|
170
|
+
less_than_or_equal_to: 99,
|
171
|
+
only_integer: true
|
152
172
|
validates_numericality_of :amount,
|
153
|
-
:
|
154
|
-
:
|
155
|
-
:
|
173
|
+
greater_than: :min_amount,
|
174
|
+
less_than: :max_amount,
|
175
|
+
only_integer: true
|
156
176
|
validates_numericality_of :attempts,
|
157
|
-
:
|
158
|
-
:
|
159
|
-
:
|
160
|
-
validates_length_of :name, :
|
161
|
-
validates_length_of :description, :
|
162
|
-
validates_length_of :action, :
|
163
|
-
validates_length_of :home_picture, :
|
177
|
+
greater_than_or_equal_to: :min_attempts,
|
178
|
+
less_than_or_equal_to: :max_attempts,
|
179
|
+
only_integer: true
|
180
|
+
validates_length_of :name, maximum: 25
|
181
|
+
validates_length_of :description, maximum: 50
|
182
|
+
validates_length_of :action, maximum: 10, tokenizer: lambda { |str| str.scan(/\w+/) }
|
183
|
+
validates_length_of :home_picture, is: 12
|
164
184
|
|
165
185
|
def min_amount
|
166
186
|
10
|
@@ -182,26 +202,21 @@ end
|
|
182
202
|
class OtherValidatingUser < User
|
183
203
|
include ActiveModel::Validations
|
184
204
|
validates_numericality_of :age,
|
185
|
-
:
|
186
|
-
:
|
187
|
-
:
|
205
|
+
greater_than: 17,
|
206
|
+
less_than: 100,
|
207
|
+
only_integer: true
|
188
208
|
validates_numericality_of :amount,
|
189
|
-
:
|
190
|
-
:
|
191
|
-
:
|
209
|
+
greater_than: Proc.new { |user| user.age },
|
210
|
+
less_than: Proc.new { |user| user.age + 100 },
|
211
|
+
only_integer: true
|
192
212
|
validates_numericality_of :attempts,
|
193
|
-
:
|
194
|
-
:
|
195
|
-
:
|
213
|
+
greater_than_or_equal_to: Proc.new { |user| user.age },
|
214
|
+
less_than_or_equal_to: Proc.new { |user| user.age + 100 },
|
215
|
+
only_integer: true
|
196
216
|
|
197
|
-
validates_format_of :country, :
|
198
|
-
|
199
|
-
|
200
|
-
if ActiveModel::VERSION::MAJOR == 3 && ActiveModel::VERSION::MINOR >= 1
|
201
|
-
validates_format_of :name, :with => Proc.new { /\w+/ }
|
202
|
-
else
|
203
|
-
validates_format_of :name, :with => /\w+/
|
204
|
-
end
|
217
|
+
validates_format_of :country, with: /\w+/
|
218
|
+
validates_format_of :name, with: Proc.new { /\w+/ }
|
219
|
+
validates_format_of :description, without: /\d+/
|
205
220
|
end
|
206
221
|
|
207
222
|
class HashBackedAuthor < Hash
|
data/test/test_helper.rb
CHANGED
@@ -1,16 +1,12 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'bundler/setup'
|
3
2
|
|
4
|
-
require '
|
5
|
-
require 'mocha'
|
3
|
+
require 'minitest/autorun'
|
6
4
|
|
7
5
|
require 'active_model'
|
8
6
|
require 'action_controller'
|
9
7
|
require 'action_view'
|
10
8
|
require 'action_view/template'
|
11
9
|
|
12
|
-
# Rails 3.0.4 is missing this "deprecation" require.
|
13
|
-
require 'active_support/core_ext/module/deprecation'
|
14
10
|
require 'action_view/test_case'
|
15
11
|
|
16
12
|
module Rails
|
@@ -39,40 +35,27 @@ class ActionView::TestCase
|
|
39
35
|
include SimpleForm::ActionViewExtensions::FormHelper
|
40
36
|
|
41
37
|
setup :set_controller
|
42
|
-
setup :
|
38
|
+
setup :setup_users
|
43
39
|
|
44
40
|
def set_controller
|
45
41
|
@controller = MockController.new
|
46
42
|
end
|
47
43
|
|
48
|
-
def
|
49
|
-
@user = User.
|
50
|
-
|
51
|
-
|
52
|
-
:
|
53
|
-
:
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
:
|
61
|
-
:
|
62
|
-
|
63
|
-
:amount => 15,
|
64
|
-
:attempts => 1,
|
65
|
-
:company => [1]
|
66
|
-
}.merge(options))
|
67
|
-
|
68
|
-
@other_validating_user = OtherValidatingUser.new({
|
69
|
-
:id => 1,
|
70
|
-
:name => 'New in SimpleForm!',
|
71
|
-
:description => 'Hello!',
|
72
|
-
:created_at => Time.now,
|
73
|
-
:age => 19,
|
74
|
-
:company => 1
|
75
|
-
}.merge(options))
|
44
|
+
def setup_users(extra_attributes = {})
|
45
|
+
@user = User.build(extra_attributes)
|
46
|
+
|
47
|
+
@validating_user = ValidatingUser.build({
|
48
|
+
home_picture: 'Home picture',
|
49
|
+
age: 19,
|
50
|
+
amount: 15,
|
51
|
+
attempts: 1,
|
52
|
+
company: [1]
|
53
|
+
}.merge!(extra_attributes))
|
54
|
+
|
55
|
+
@other_validating_user = OtherValidatingUser.build({
|
56
|
+
age: 19,
|
57
|
+
company: 1
|
58
|
+
}.merge!(extra_attributes))
|
76
59
|
end
|
77
60
|
|
78
61
|
def protect_against_forgery?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- José Valim
|
@@ -10,36 +10,48 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2013-09-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemodel
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 4.0.0
|
22
|
+
- - <
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '4.1'
|
22
25
|
type: :runtime
|
23
26
|
prerelease: false
|
24
27
|
version_requirements: !ruby/object:Gem::Requirement
|
25
28
|
requirements:
|
26
|
-
- -
|
29
|
+
- - '>='
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 4.0.0
|
32
|
+
- - <
|
27
33
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
34
|
+
version: '4.1'
|
29
35
|
- !ruby/object:Gem::Dependency
|
30
36
|
name: actionpack
|
31
37
|
requirement: !ruby/object:Gem::Requirement
|
32
38
|
requirements:
|
33
|
-
- -
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 4.0.0
|
42
|
+
- - <
|
34
43
|
- !ruby/object:Gem::Version
|
35
|
-
version: '
|
44
|
+
version: '4.1'
|
36
45
|
type: :runtime
|
37
46
|
prerelease: false
|
38
47
|
version_requirements: !ruby/object:Gem::Requirement
|
39
48
|
requirements:
|
40
|
-
- -
|
49
|
+
- - '>='
|
41
50
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
51
|
+
version: 4.0.0
|
52
|
+
- - <
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.1'
|
43
55
|
description: Forms made easy!
|
44
56
|
email: contact@plataformatec.com.br
|
45
57
|
executables: []
|
@@ -49,9 +61,7 @@ files:
|
|
49
61
|
- CHANGELOG.md
|
50
62
|
- MIT-LICENSE
|
51
63
|
- README.md
|
52
|
-
- lib/generators/simple_form/USAGE
|
53
64
|
- lib/generators/simple_form/install_generator.rb
|
54
|
-
- lib/generators/simple_form/templates/README
|
55
65
|
- lib/generators/simple_form/templates/_form.html.erb
|
56
66
|
- lib/generators/simple_form/templates/_form.html.haml
|
57
67
|
- lib/generators/simple_form/templates/_form.html.slim
|
@@ -59,10 +69,11 @@ files:
|
|
59
69
|
- lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb
|
60
70
|
- lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb
|
61
71
|
- lib/generators/simple_form/templates/config/locales/simple_form.en.yml
|
62
|
-
- lib/simple_form
|
72
|
+
- lib/generators/simple_form/templates/README
|
73
|
+
- lib/generators/simple_form/USAGE
|
63
74
|
- lib/simple_form/action_view_extensions/builder.rb
|
75
|
+
- lib/simple_form/action_view_extensions/builder.rb.orig
|
64
76
|
- lib/simple_form/action_view_extensions/form_helper.rb
|
65
|
-
- lib/simple_form/components.rb
|
66
77
|
- lib/simple_form/components/errors.rb
|
67
78
|
- lib/simple_form/components/hints.rb
|
68
79
|
- lib/simple_form/components/html5.rb
|
@@ -73,17 +84,17 @@ files:
|
|
73
84
|
- lib/simple_form/components/pattern.rb
|
74
85
|
- lib/simple_form/components/placeholders.rb
|
75
86
|
- lib/simple_form/components/readonly.rb
|
76
|
-
- lib/simple_form/
|
87
|
+
- lib/simple_form/components.rb
|
77
88
|
- lib/simple_form/error_notification.rb
|
78
89
|
- lib/simple_form/form_builder.rb
|
79
|
-
- lib/simple_form/
|
90
|
+
- lib/simple_form/form_builder.rb.orig
|
80
91
|
- lib/simple_form/helpers/autofocus.rb
|
81
92
|
- lib/simple_form/helpers/disabled.rb
|
82
93
|
- lib/simple_form/helpers/readonly.rb
|
83
94
|
- lib/simple_form/helpers/required.rb
|
84
95
|
- lib/simple_form/helpers/validators.rb
|
96
|
+
- lib/simple_form/helpers.rb
|
85
97
|
- lib/simple_form/i18n_cache.rb
|
86
|
-
- lib/simple_form/inputs.rb
|
87
98
|
- lib/simple_form/inputs/base.rb
|
88
99
|
- lib/simple_form/inputs/block_input.rb
|
89
100
|
- lib/simple_form/inputs/boolean_input.rb
|
@@ -101,13 +112,18 @@ files:
|
|
101
112
|
- lib/simple_form/inputs/range_input.rb
|
102
113
|
- lib/simple_form/inputs/string_input.rb
|
103
114
|
- lib/simple_form/inputs/text_input.rb
|
115
|
+
- lib/simple_form/inputs.rb
|
104
116
|
- lib/simple_form/map_type.rb
|
117
|
+
- lib/simple_form/railtie.rb
|
118
|
+
- lib/simple_form/tags.rb
|
105
119
|
- lib/simple_form/version.rb
|
106
|
-
- lib/simple_form/
|
120
|
+
- lib/simple_form/version.rb.orig
|
107
121
|
- lib/simple_form/wrappers/builder.rb
|
108
122
|
- lib/simple_form/wrappers/many.rb
|
109
123
|
- lib/simple_form/wrappers/root.rb
|
110
124
|
- lib/simple_form/wrappers/single.rb
|
125
|
+
- lib/simple_form/wrappers.rb
|
126
|
+
- lib/simple_form.rb
|
111
127
|
- test/action_view_extensions/builder_test.rb
|
112
128
|
- test/action_view_extensions/form_helper_test.rb
|
113
129
|
- test/components/label_test.rb
|
@@ -145,7 +161,8 @@ files:
|
|
145
161
|
- test/support/models.rb
|
146
162
|
- test/test_helper.rb
|
147
163
|
homepage: https://github.com/plataformatec/simple_form
|
148
|
-
licenses:
|
164
|
+
licenses:
|
165
|
+
- MIT
|
149
166
|
metadata: {}
|
150
167
|
post_install_message:
|
151
168
|
rdoc_options: []
|
@@ -153,17 +170,17 @@ require_paths:
|
|
153
170
|
- lib
|
154
171
|
required_ruby_version: !ruby/object:Gem::Requirement
|
155
172
|
requirements:
|
156
|
-
- -
|
173
|
+
- - '>='
|
157
174
|
- !ruby/object:Gem::Version
|
158
175
|
version: '0'
|
159
176
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
177
|
requirements:
|
161
|
-
- -
|
178
|
+
- - '>='
|
162
179
|
- !ruby/object:Gem::Version
|
163
180
|
version: '0'
|
164
181
|
requirements: []
|
165
182
|
rubyforge_project: simple_form
|
166
|
-
rubygems_version: 2.
|
183
|
+
rubygems_version: 2.0.6
|
167
184
|
signing_key:
|
168
185
|
specification_version: 4
|
169
186
|
summary: Forms made easy!
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# TODO: Delete this file when we drop support for Rails 3.0
|
2
|
-
# This method is already implemented in active_support 3.1
|
3
|
-
|
4
|
-
unless Hash.new.respond_to?(:deep_dup)
|
5
|
-
class Hash
|
6
|
-
# Returns a deep copy of hash.
|
7
|
-
def deep_dup
|
8
|
-
duplicate = self.dup
|
9
|
-
duplicate.each_pair do |k,v|
|
10
|
-
tv = duplicate[k]
|
11
|
-
duplicate[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_dup : v
|
12
|
-
end
|
13
|
-
duplicate
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|