Sha256: 0ef4386385842cc969786ee3936ce528ba13695aba3f60c59ca6a6622762a3e1

Contents?: true

Size: 783 Bytes

Versions: 6

Compression:

Stored size: 783 Bytes

Contents

module Katello
  class RepositoryType
    class << self
      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
    end

    def_field :allow_creation_by_user, :service_class
    attr_reader :id

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

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

    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
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
katello-3.10.2 app/services/katello/repository_type.rb
katello-3.10.1.1 app/services/katello/repository_type.rb
katello-3.10.1 app/services/katello/repository_type.rb
katello-3.10.0 app/services/katello/repository_type.rb
katello-3.10.0.rc1.1 app/services/katello/repository_type.rb
katello-3.10.0.rc1 app/services/katello/repository_type.rb