Class: Content::ContentViewFactory

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Includes:
ActiveModel::Conversion
Defined in:
app/services/content/content_view_factory.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ContentViewFactory

Returns a new instance of ContentViewFactory.



31
32
33
34
35
# File 'app/services/content/content_view_factory.rb', line 31

def initialize(attributes = {})
  attributes.each do |name, value|
    instance_variable_set("@#{name}", value) if respond_to?("#{name}".to_sym)
  end
end

Instance Attribute Details

#originator_idObject

Returns the value of attribute originator_id.



6
7
8
# File 'app/services/content/content_view_factory.rb', line 6

def originator_id
  @originator_id
end

#os_cvObject

Returns the value of attribute os_cv.



6
7
8
# File 'app/services/content/content_view_factory.rb', line 6

def os_cv
  @os_cv
end

#parent_cvObject

Returns the value of attribute parent_cv.



6
7
8
# File 'app/services/content/content_view_factory.rb', line 6

def parent_cv
  @parent_cv
end

#product_cvObject

Returns the value of attribute product_cv.



6
7
8
# File 'app/services/content/content_view_factory.rb', line 6

def product_cv
  @product_cv
end

#typeObject

Returns the value of attribute type.



6
7
8
# File 'app/services/content/content_view_factory.rb', line 6

def type
  @type
end

Class Method Details

.create_composite_content_view(options = {}) ⇒ Object

create a composite content view of a hostgroup (the hostgroup may have a list of products) and a parent content view. The parent content view is one of the hostgroup parent content views. A hostgroup may have number of content views representing different versions of that hostgroup content.



22
23
24
25
26
27
28
29
# File 'app/services/content/content_view_factory.rb', line 22

def self.create_composite_content_view(options = {})
  factory   = new(options)
  hostgroup = Hostgroup.find_by_id(factory.originator_id)
  clone_ids = Content::RepositoryClone.for_content_views([factory.product_cv, factory.os_cv]).
    pluck(:id)
  ContentView.new(:source_repositories=> [], :originator => hostgroup,
                  :repository_clone_ids => clone_ids, :parent_id => factory.parent_cv)
end

.create_os_content_view(operatingsystem_id) ⇒ Object

create a content view of an operating system



14
15
16
17
# File 'app/services/content/content_view_factory.rb', line 14

def self.create_os_content_view(operatingsystem_id)
  os = Operatingsystem.find_by_id(operatingsystem_id)
  ContentView.new(:source_repositories => os.repositories, :originator => os)
end

.create_product_content_view(product_id) ⇒ Object

create a content view of a single product



8
9
10
11
# File 'app/services/content/content_view_factory.rb', line 8

def self.create_product_content_view(product_id)
  product = Product.find_by_id(product_id)
  ContentView.new(:source_repositories => product.repositories, :originator => product)
end

Instance Method Details

#persisted?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'app/services/content/content_view_factory.rb', line 37

def persisted?
  false
end