Class: PuppetX::Puppetlabs::Migration::CatalogDeltaModel::Resource
- Inherits:
-
Diff
- Object
- DeltaEntity
- Diff
- PuppetX::Puppetlabs::Migration::CatalogDeltaModel::Resource
- Defined in:
- lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb
Overview
Represents a resource in the Catalog.
Instance Attribute Summary collapse
- #attributes ⇒ Object readonly
- #location ⇒ Object readonly
- #title ⇒ Object readonly
- #type ⇒ Object readonly
Attributes inherited from Diff
Instance Method Summary collapse
- #assign_ids(start) ⇒ Object
-
#clear_attributes ⇒ Object
private
Set the attributes instance variable to ‘nil`.
-
#initialize(location, type, title, attributes) ⇒ Resource
constructor
A new instance of Resource.
- #initialize_from_hash(hash) ⇒ Object
-
#key ⇒ String
Returns the key that uniquely identifies the Resource.
Methods inherited from DeltaEntity
Methods included from ModelObject
Constructor Details
#initialize(location, type, title, attributes) ⇒ Resource
Returns a new instance of Resource.
231 232 233 234 235 236 |
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 231 def initialize(location, type, title, attributes) @location = location @type = assert_type(String, type) @title = assert_type(String, title) @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
225 226 227 |
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 225 def attributes @attributes end |
#location ⇒ Object (readonly)
206 207 208 |
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 206 def location @location end |
#title ⇒ Object (readonly)
216 217 218 |
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 216 def title @title end |
#type ⇒ Object (readonly)
211 212 213 |
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 211 def type @type end |
Instance Method Details
#assign_ids(start) ⇒ Object
247 248 249 250 |
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 247 def assign_ids(start) @attributes = @attributes.values if @attributes.is_a?(Hash) assign_ids_on_each(super(start), @attributes) end |
#clear_attributes ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set the attributes instance variable to ‘nil`. This is done for all resources in the delta unless the production is flagged as verbose
256 257 258 |
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 256 def clear_attributes @attributes = nil end |
#initialize_from_hash(hash) ⇒ Object
260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 260 def initialize_from_hash(hash) hash.each_pair do |k, v| k = :"@#{k}" instance_variable_set(k, case k when :@location Location.from_hash(v) when :@attributes v.map { |rh| Attribute.from_hash(rh) } else v end) end end |
#key ⇒ String
Returns the key that uniquely identifies the Resource. The key is used when finding added, missing, equal, and conflicting resources in the compared catalogs.
243 244 245 |
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 243 def key "#{@type}{#{@title}}]" end |