Class: Ynl::Models::AttributeSubset
- Inherits:
-
Object
- Object
- Ynl::Models::AttributeSubset
- Defined in:
- lib/ynl/models.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#superset ⇒ Object
readonly
Returns the value of attribute superset.
Instance Method Summary collapse
- #attributes ⇒ Object
-
#initialize(name:, superset:, attributes:, doc:) ⇒ AttributeSubset
constructor
A new instance of AttributeSubset.
- #resolve(f) ⇒ Object
Constructor Details
#initialize(name:, superset:, attributes:, doc:) ⇒ AttributeSubset
Returns a new instance of AttributeSubset.
129 130 131 132 133 134 |
# File 'lib/ynl/models.rb', line 129 def initialize(name:, superset:, attributes:, doc:) @name = name @superset = superset @attributes = attributes @doc = doc end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
127 128 129 |
# File 'lib/ynl/models.rb', line 127 def doc @doc end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
127 128 129 |
# File 'lib/ynl/models.rb', line 127 def name @name end |
#superset ⇒ Object (readonly)
Returns the value of attribute superset.
127 128 129 |
# File 'lib/ynl/models.rb', line 127 def superset @superset end |
Instance Method Details
#attributes ⇒ Object
136 137 138 139 140 141 142 143 144 |
# File 'lib/ynl/models.rb', line 136 def attributes # WORKAROUND: Some upstream specs (e.g. devlink) contain duplicate attribute # entries in subset-of attribute sets. Deduplicate by name here until the # upstream specs are fixed. @attributes.uniq {|attr| attr.fetch('name') }.map do |attr| name = attr.fetch('name') superset.attributes.find { it.name == name } or raise ParseError "No attribute with name #{name}" end end |
#resolve(f) ⇒ Object
146 147 148 |
# File 'lib/ynl/models.rb', line 146 def resolve(f) self end |