Class: Katello::RepositoryType

Inherits:
Object
  • Object
show all
Defined in:
app/services/katello/repository_type.rb

Defined Under Namespace

Classes: ContentType, GenericContentType, GenericImportAttribute, GenericRemoteOption

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ RepositoryType

Returns a new instance of RepositoryType.



26
27
28
29
30
31
32
33
# File 'app/services/katello/repository_type.rb', line 26

def initialize(id)
  @id = id.to_sym
  allow_creation_by_user(true)
  @unique_content_per_repo = false
  @content_types = []
  @generic_remote_options = []
  @import_attributes = []
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



23
24
25
# File 'app/services/katello/repository_type.rb', line 23

def id
  @id
end

#index_additional_data_procObject

Returns the value of attribute index_additional_data_proc.



22
23
24
# File 'app/services/katello/repository_type.rb', line 22

def index_additional_data_proc
  @index_additional_data_proc
end

#metadata_publish_matching_checkObject

Returns the value of attribute metadata_publish_matching_check.



22
23
24
# File 'app/services/katello/repository_type.rb', line 22

def 
  
end

#unique_content_per_repoObject (readonly)

Returns the value of attribute unique_content_per_repo.



23
24
25
# File 'app/services/katello/repository_type.rb', line 23

def unique_content_per_repo
  @unique_content_per_repo
end

#url_description=(value) ⇒ Object (writeonly)

Sets the attribute url_description

Parameters:

  • value

    the value to set the attribute url_description to.



24
25
26
# File 'app/services/katello/repository_type.rb', line 24

def url_description=(value)
  @url_description = value
end

Class Method Details

.def_field(*names) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'app/services/katello/repository_type.rb', line 4

def def_field(*names)
  class_eval do
    names.each do |name|
      define_method(name) do |*args|
        args.empty? ? instance_variable_get("@#{name}") : instance_variable_set("@#{name}", *args)
      end
    end
  end
end

Instance Method Details

#<=>(other) ⇒ Object



113
114
115
# File 'app/services/katello/repository_type.rb', line 113

def <=>(other)
  self.id.to_s <=> other.id.to_s
end

#as_json(_options = {}) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
# File 'app/services/katello/repository_type.rb', line 117

def as_json(_options = {})
  {
    :name => self.id.to_s,
    :id => self.id,
    :creatable => @allow_creation_by_user,
    :pulp3_support => SmartProxy.pulp_primary.pulp3_repository_type_support?(self),
    :generic_remote_options => translated_generic_remote_options,
    :import_attributes => translated_import_attributes,
    :url_description => _(@url_description),
    :content_types => content_types.as_json
  }
end

#content_type(model_class, options = {}) ⇒ Object



86
87
88
89
# File 'app/services/katello/repository_type.rb', line 86

def content_type(model_class, options = {})
  @content_types ||= []
  @content_types << ContentType.new(options.merge(:model_class => model_class, :content_type => model_class::CONTENT_TYPE))
end

#content_typesObject



39
40
41
# File 'app/services/katello/repository_type.rb', line 39

def content_types
  @content_types.sort_by(&:priority)
end

#content_types_to_indexObject



74
75
76
# File 'app/services/katello/repository_type.rb', line 74

def content_types_to_index
  @content_types.select { |type| type.index }
end

#default_managed_content_type(label = nil) ⇒ Object



78
79
80
81
82
83
84
# File 'app/services/katello/repository_type.rb', line 78

def default_managed_content_type(label = nil)
  if label
    @default_managed_content_type_label = label.to_s
  else
    @content_types.find { |content_type| content_type.label == @default_managed_content_type_label }
  end
end

#generic_content_type(content_type, options = {}) ⇒ Object



91
92
93
94
# File 'app/services/katello/repository_type.rb', line 91

def generic_content_type(content_type, options = {})
  @content_types ||= []
  @content_types << GenericContentType.new(options.merge(:content_type => content_type))
end

#generic_remote_option(name, options = {}) ⇒ Object



96
97
98
99
# File 'app/services/katello/repository_type.rb', line 96

def generic_remote_option(name, options = {})
  @generic_remote_options ||= []
  @generic_remote_options << GenericRemoteOption.new(options.merge(:name => name))
end

#generic_remote_optionsObject



43
44
45
# File 'app/services/katello/repository_type.rb', line 43

def generic_remote_options
  @generic_remote_options.sort_by(&:name)
end

#import_attribute(name, options = {}) ⇒ Object



101
102
103
# File 'app/services/katello/repository_type.rb', line 101

def import_attribute(name, options = {})
  @import_attributes << GenericImportAttribute.new(options.merge(:name => name))
end

#import_attributesObject



47
48
49
# File 'app/services/katello/repository_type.rb', line 47

def import_attributes
  @import_attributes.sort_by(&:name)
end

#index_additional_data(&block) ⇒ Object



109
110
111
# File 'app/services/katello/repository_type.rb', line 109

def index_additional_data(&block)
  self.index_additional_data_proc = block
end

#inspectObject



130
131
132
# File 'app/services/katello/repository_type.rb', line 130

def inspect
  "RepositoryType[#{self.id}]"
end

#prevent_unneeded_metadata_publishObject



105
106
107
# File 'app/services/katello/repository_type.rb', line 105

def 
  self. = true
end

#primary_content_typesObject



51
52
53
54
55
# File 'app/services/katello/repository_type.rb', line 51

def primary_content_types
  found = self.content_types.select { |type| type.primary_content }
  found = self.content_types if found.empty?
  found
end

#pulp3_api(smart_proxy) ⇒ Object



134
135
136
137
138
139
140
# File 'app/services/katello/repository_type.rb', line 134

def pulp3_api(smart_proxy)
  if pulp3_api_class == Katello::Pulp3::Api::Generic
    pulp3_api_class.new(smart_proxy, self)
  else
    pulp3_api_class ? pulp3_api_class.new(smart_proxy, self) : Katello::Pulp3::Api::Core.new(smart_proxy)
  end
end

#set_unique_content_per_repoObject



35
36
37
# File 'app/services/katello/repository_type.rb', line 35

def set_unique_content_per_repo
  @unique_content_per_repo = true
end

#translated_generic_remote_optionsObject



57
58
59
60
61
62
63
64
# File 'app/services/katello/repository_type.rb', line 57

def translated_generic_remote_options
  translated = generic_remote_options.deep_dup
  translated.map do |option|
    option.title = _(option.title)
    option.description = _(option.description)
  end
  translated
end

#translated_import_attributesObject



66
67
68
69
70
71
72
# File 'app/services/katello/repository_type.rb', line 66

def translated_import_attributes
  translated = import_attributes.deep_dup
  translated.map do |option|
    option.description = _(option.description)
  end
  translated
end