Class: Udb::Parameter
Overview
A parameter (AKA option, AKA implementation-defined value) supported by an extension
Defined Under Namespace
Classes: NoMatchingSchemaError
Instance Attribute Summary collapse
#arch, #data, #data_path, #long_name
Instance Method Summary
collapse
create_json_schemer_resolver, #key?, #keys, #validate
#__source, #cfg_arch?, #clone, #defer, #defined_by_condition, #description, #inspect, #kind, #source_line
Constructor Details
#initialize(yaml, data_path, cfg_arch) ⇒ Parameter
Returns a new instance of Parameter.
69
70
71
72
73
|
# File 'lib/udb/obj/parameter.rb', line 69
def initialize(yaml, data_path, cfg_arch)
super(yaml, data_path, cfg_arch)
@schema = Schema.new(data["schema"])
end
|
Instance Attribute Details
#cfg_arch ⇒ Object
Returns the value of attribute cfg_arch.
25
26
27
|
# File 'lib/udb/obj/parameter.rb', line 25
def cfg_arch
@cfg_arch
end
|
#schema ⇒ Object
Returns the value of attribute schema.
77
78
79
|
# File 'lib/udb/obj/parameter.rb', line 77
def schema
@schema
end
|
Instance Method Details
#<=>(other) ⇒ Object
109
110
111
112
113
|
# File 'lib/udb/obj/parameter.rb', line 109
def <=>(other)
return nil unless other.is_a?(Idl::RuntimeParam)
@name <=> other.name
end
|
#default ⇒ Object
56
57
58
59
60
|
# File 'lib/udb/obj/parameter.rb', line 56
def default
if T.cast(@data["schema"], T::Hash[String, Object]).key?("default")
T.cast(@data["schema"], T::Hash[String, Object])["default"]
end
end
|
#defined_in_cfg?(cfg_arch) ⇒ Boolean
89
90
91
|
# File 'lib/udb/obj/parameter.rb', line 89
def defined_in_cfg?(cfg_arch)
defined_by_condition.satisfied_by_cfg_arch?(cfg_arch)
end
|
#idl_type ⇒ Object
83
84
85
|
# File 'lib/udb/obj/parameter.rb', line 83
def idl_type
@idl_type ||= schema.to_idl_type.make_const.freeze
end
|
#name ⇒ Object
29
|
# File 'lib/udb/obj/parameter.rb', line 29
def name = @name
|
#name_potentially_with_link(in_scope_exts) ⇒ Object
97
98
99
100
101
102
103
104
105
|
# File 'lib/udb/obj/parameter.rb', line 97
def name_potentially_with_link(in_scope_exts)
helper = Class.new do include Udb::Helpers::TemplateHelpers end
if in_scope_exts.size == 1
helper.new.link_to_udb_doc_ext_param(in_scope_exts.fetch(0).name, name, name)
else
name
end
end
|
#requirements_condition ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/udb/obj/parameter.rb', line 38
def requirements_condition
@requirements_condition ||=
begin
if @data["requirements"].nil?
AlwaysTrueCondition.new(@cfg_arch)
else
Condition.new(
@data.fetch("requirements"),
@cfg_arch,
input_file: Pathname.new(__source),
input_line: source_line(["requirements"])
)
end
end
end
|
#schema_type ⇒ Object
33
34
35
|
# File 'lib/udb/obj/parameter.rb', line 33
def schema_type
schema.to_pretty_s
end
|
#to_idl ⇒ Object
116
|
# File 'lib/udb/obj/parameter.rb', line 116
def to_idl = "#{idl_type.to_idl} #{name}"
|
#value ⇒ Object
122
|
# File 'lib/udb/obj/parameter.rb', line 122
def value = raise "Parameter value not known for #{name}"
|
#value_known? ⇒ Boolean
119
|
# File 'lib/udb/obj/parameter.rb', line 119
def value_known? = false
|