Class: Katello::RepositoryType
- Inherits:
-
Object
- Object
- Katello::RepositoryType
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
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
#id ⇒ Object
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_proc ⇒ Object
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
|
Returns the value of attribute metadata_publish_matching_check.
22
23
24
|
# File 'app/services/katello/repository_type.rb', line 22
def metadata_publish_matching_check
@metadata_publish_matching_check
end
|
#unique_content_per_repo ⇒ Object
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
Sets the attribute url_description
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_types ⇒ Object
39
40
41
|
# File 'app/services/katello/repository_type.rb', line 39
def content_types
@content_types.sort_by(&:priority)
end
|
#content_types_to_index ⇒ Object
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_options ⇒ Object
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_attributes ⇒ Object
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
|
#inspect ⇒ Object
130
131
132
|
# File 'app/services/katello/repository_type.rb', line 130
def inspect
"RepositoryType[#{self.id}]"
end
|
105
106
107
|
# File 'app/services/katello/repository_type.rb', line 105
def prevent_unneeded_metadata_publish
self.metadata_publish_matching_check = true
end
|
#primary_content_types ⇒ Object
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_repo ⇒ Object
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_options ⇒ Object
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_attributes ⇒ Object
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
|