Sha256: a27dcd2f954ce6a5be9aa278eb4690e1317f23164285c6ccff18381b8833647f
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
# # Copyright 2014 Red Hat, Inc. # # This software is licensed to you under the GNU General Public # License as published by the Free Software Foundation; either version # 2 of the License (GPLv2) or (at your option) any later version. # There is NO WARRANTY for this software, express or implied, # including the implied warranties of MERCHANTABILITY, # NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should # have received a copy of GPLv2 along with this software; if not, see # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. module Katello module Glue::Pulp::Distribution def self.included(base) base.send :include, InstanceMethods base.class_eval do attr_accessor :_id, :id, :description, :files, :family, :variant, :version, :url, :arch, :repoids def self.find(id) Katello::Distribution.new(Katello.pulp_server.extensions.distribution.find(id)) end end end module InstanceMethods def initialize(attrs = {}, _options = {}) attrs[:repoids] = attrs.delete(:repository_memberships) generate_instance_variables(attrs) end def generate_instance_variables(attrs) attrs.each_pair do |k, v| if self.class.method_defined?(k) && !v.nil? instance_variable_set("@#{k}", v) end end end def as_json(*args) result = super(*args) result['files'] = (result['files'] || []).inject([]) do |paths, file| paths << file['relativepath'] end result end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
katello-2.2.2 | app/models/katello/glue/pulp/distribution.rb |