Class: Katello::RepositoryType

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ RepositoryType



18
19
20
21
# File 'app/services/katello/repository_type.rb', line 18

def initialize(id)
  @id = id.to_sym
  allow_creation_by_user(true)
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



16
17
18
# File 'app/services/katello/repository_type.rb', line 16

def id
  @id
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



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

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

#as_json(options = {}) ⇒ Object



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

def as_json(options = {})
  ret = super(options)
  ret[:name] = self.id.to_s
  ret[:creatable] = @allow_creation_by_user
  ret.delete("allow_creation_by_user")
  ret
end