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`.
- #finish_attributes ⇒ Object
-
#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.
240 241 242 243 244 245 |
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 240 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)
234 235 236 |
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 234 def attributes @attributes end |
#location ⇒ Object (readonly)
215 216 217 |
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 215 def location @location end |
#title ⇒ Object (readonly)
225 226 227 |
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 225 def title @title end |
#type ⇒ Object (readonly)
220 221 222 |
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 220 def type @type end |
Instance Method Details
#assign_ids(start) ⇒ Object
256 257 258 |
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 256 def assign_ids(start) 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
264 265 266 |
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 264 def clear_attributes @attributes = nil end |
#finish_attributes ⇒ Object
268 269 270 |
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 268 def finish_attributes @attributes = @attributes.values.each { |v| v.finish } if @attributes.is_a?(Hash) end |
#initialize_from_hash(hash) ⇒ Object
272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 272 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.
252 253 254 |
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 252 def key "#{@type}{#{@title}}]" end |