Sha256: 4fe4db0ccb37c08af7e98c955197280bfb3cb6cb245ded0d72be8978f7603442

Contents?: true

Size: 893 Bytes

Versions: 4

Compression:

Stored size: 893 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_accessor :metadata_publish_matching_check
    attr_reader :id

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

    def prevent_unneeded_metadata_publish
      self.metadata_publish_matching_check = true
    end

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

    def as_json(_options = {})
      {
        :name => self.id.to_s,
        :id => self.id,
        :creatable => @allow_creation_by_user
      }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
katello-3.11.2 app/services/katello/repository_type.rb
katello-3.11.1 app/services/katello/repository_type.rb
katello-3.11.0 app/services/katello/repository_type.rb
katello-3.11.0.rc2 app/services/katello/repository_type.rb