File tree 1 file changed +15
-11
lines changed
1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -121,18 +121,22 @@ class << self
121
121
# monograph = Monograph.new
122
122
# change_set = Hyrax::Forms::ResourceForm.for(monograph)
123
123
def for ( resource )
124
- "#{ resource . class . name } Form" . constantize . new ( resource )
125
- rescue NameError => _err
126
- case resource
127
- when Hyrax ::AdministrativeSet
128
- Hyrax ::Forms ::AdministrativeSetForm . new ( resource )
129
- when Hyrax ::FileSet
130
- Hyrax ::Forms ::FileSetForm . new ( resource )
131
- when Hyrax ::PcdmCollection
132
- Hyrax ::Forms ::PcdmCollectionForm . new ( resource )
124
+ klass = "#{ resource . class . name } Form" . safe_constantize
125
+
126
+ if klass
127
+ klass . new ( resource )
133
128
else
134
- # NOTE: This will create a +Hyrax::Forms::PcdmObjectForm+.
135
- Hyrax ::Forms ::ResourceForm ( resource . class ) . new ( resource )
129
+ case resource
130
+ when Hyrax ::AdministrativeSet
131
+ Hyrax ::Forms ::AdministrativeSetForm . new ( resource )
132
+ when Hyrax ::FileSet
133
+ Hyrax ::Forms ::FileSetForm . new ( resource )
134
+ when Hyrax ::PcdmCollection
135
+ Hyrax ::Forms ::PcdmCollectionForm . new ( resource )
136
+ else
137
+ # NOTE: This will create a +Hyrax::Forms::PcdmObjectForm+.
138
+ Hyrax ::Forms ::ResourceForm ( resource . class ) . new ( resource )
139
+ end
136
140
end
137
141
end
138
142
You can’t perform that action at this time.
0 commit comments