Class: Content::ContentViewFactory
- Inherits:
-
Object
- Object
- Content::ContentViewFactory
- Extended by:
- ActiveModel::Naming
- Includes:
- ActiveModel::Conversion
- Defined in:
- app/services/content/content_view_factory.rb
Instance Attribute Summary collapse
-
#originator_id ⇒ Object
Returns the value of attribute originator_id.
-
#os_cv ⇒ Object
Returns the value of attribute os_cv.
-
#parent_cv ⇒ Object
Returns the value of attribute parent_cv.
-
#product_cv ⇒ Object
Returns the value of attribute product_cv.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
-
.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.
-
.create_os_content_view(operatingsystem_id) ⇒ Object
create a content view of an operating system.
-
.create_product_content_view(product_id) ⇒ Object
create a content view of a single product.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ ContentViewFactory
constructor
A new instance of ContentViewFactory.
- #persisted? ⇒ Boolean
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_id ⇒ Object
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_cv ⇒ Object
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_cv ⇒ Object
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_cv ⇒ Object
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 |
#type ⇒ Object
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( = {}) factory = new() 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() os = .find_by_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
37 38 39 |
# File 'app/services/content/content_view_factory.rb', line 37 def persisted? false end |