Class: Udb::Parameter
- Inherits:
-
TopLevelDatabaseObject
- Object
- DatabaseObject
- TopLevelDatabaseObject
- Udb::Parameter
- Extended by:
- T::Sig
- Includes:
- Idl::RuntimeParam
- Defined in:
- lib/udb/obj/parameter.rb
Overview
A parameter (AKA option, AKA implementation-defined value) supported by an extension
Defined Under Namespace
Classes: NoMatchingSchemaError
Instance Attribute Summary collapse
-
#cfg_arch ⇒ ConfiguredArchitecture
readonly
The defining architecture.
-
#schema ⇒ Schema
readonly
JSON Schema for this param.
Instance Method Summary collapse
-
#<=>(other) ⇒ Integer?
sorts by name.
- #default ⇒ Object?
-
#defined_in_cfg?(cfg_arch) ⇒ SatisfiedResult
If this parameter is defined in
cfg_arch. - #idl_type ⇒ Idl::Type
- #initialize(yaml, data_path, cfg_arch) constructor
-
#name ⇒ String
Parameter name.
-
#name_potentially_with_link(in_scope_exts) ⇒ String
Text to create a link to the parameter definition with the link text the parameter name.
- #requirements_condition ⇒ AbstractCondition
-
#schema_type ⇒ String
Pretty convert extension schema to a string.
- #to_idl ⇒ String
- #value ⇒ Idl::RuntimeParam::ValueType
- #value_known? ⇒ Boolean
Constructor Details
Instance Attribute Details
#cfg_arch ⇒ ConfiguredArchitecture (readonly)
Returns The defining architecture.
25 26 27 |
# File 'lib/udb/obj/parameter.rb', line 25 def cfg_arch @cfg_arch end |
#schema ⇒ Schema (readonly)
Returns JSON Schema for this param.
77 78 79 |
# File 'lib/udb/obj/parameter.rb', line 77 def schema @schema end |
Instance Method Details
#<=>(other) ⇒ Integer?
sorts by name
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) ⇒ SatisfiedResult
Returns if this parameter is defined in cfg_arch.
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 ⇒ Idl::Type
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 ⇒ String
Returns Parameter name.
29 |
# File 'lib/udb/obj/parameter.rb', line 29 def name = @name |
#name_potentially_with_link(in_scope_exts) ⇒ String
Returns Text to create a link to the parameter definition with the link text the parameter name. if only one extension defines the parameter, otherwise just the parameter name.
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 ⇒ AbstractCondition
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 ⇒ String
Pretty convert extension schema to a string.
33 34 35 |
# File 'lib/udb/obj/parameter.rb', line 33 def schema_type schema.to_pretty_s end |
#to_idl ⇒ String
116 |
# File 'lib/udb/obj/parameter.rb', line 116 def to_idl = "#{idl_type.to_idl} #{name}" |
#value ⇒ Idl::RuntimeParam::ValueType
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 |