@@ -191,7 +191,12 @@ class InScopeExtensionParameter
191191
192192 def initialize ( param_db , schema_hash , note )
193193 raise ArgumentError , "Expecting ExtensionParameter" unless param_db . is_a? ( ExtensionParameter )
194- raise ArgumentError , "Expecting schema_hash to be a hash" unless schema_hash . is_a? ( Hash )
194+
195+ if schema_hash . nil?
196+ schema_hash = { }
197+ else
198+ raise ArgumentError , "Expecting schema_hash to be a hash" unless schema_hash . is_a? ( Hash )
199+ end
195200
196201 @param_db = param_db
197202 @schema_crd = Schema . new ( schema_hash )
@@ -216,9 +221,26 @@ def value
216221 @schema_crd . value
217222 end
218223
219- # Pretty convert CRD's parameter constraint merged into extension schema to a string.
220- def schema_pretty_crd_merged_with_param_db
221- Schema . new ( @param_db . schema ) . merge! ( @schema_crd ) . to_pretty_s
224+ # @return [String] - # What parameter values are allowed by the CRD.
225+ #
226+ # Old implementation:
227+ # def schema_pretty_crd_merged_with_param_db
228+ # Schema.new(@param_db.schema).merge!(@schema_crd).to_pretty_s
229+ # end
230+ def allowed_values
231+ if ( @schema_crd . empty? )
232+ # CRD doesn't add any constraints on parameter's value.
233+ return "Any"
234+ end
235+
236+ # Create a Schema object just using information in the parameter database.
237+ schema_obj = Schema . new ( @param_db . schema )
238+
239+ # Merge in constraints imposed by the CRD on the parameter.
240+ schema_obj . merge! ( @schema_crd )
241+
242+ # Create string showing allowed values of parameter with CRD constraints added
243+ schema_obj . to_pretty_s
222244 end
223245
224246 # sorts by name
@@ -252,7 +274,7 @@ def all_in_scope_ext_params
252274 raise "There is no param '#{ param_name } ' in extension '#{ ext_crd [ "name" ] } " if param_db . nil?
253275
254276 @all_in_scope_ext_params <<
255- InScopeExtensionParameter . new ( param_db , param_data [ "schema" ] || { } , param_data [ "note" ] )
277+ InScopeExtensionParameter . new ( param_db , param_data [ "schema" ] , param_data [ "note" ] )
256278 end
257279 end
258280 @all_in_scope_ext_params
@@ -281,7 +303,7 @@ def in_scope_ext_params(ext_req)
281303 raise "There is no param '#{ param_name } ' in extension '#{ ext_crd [ "name" ] } " if ext_param_db . nil?
282304
283305 ext_params <<
284- InScopeExtensionParameter . new ( ext_param_db , param_data [ "schema" ] || { } , param_data [ "note" ] )
306+ InScopeExtensionParameter . new ( ext_param_db , param_data [ "schema" ] , param_data [ "note" ] )
285307 end
286308
287309 ext_params
0 commit comments