Class: Y2Packager::Resolvable
- Inherits:
-
Object
- Object
- Y2Packager::Resolvable
- Includes:
- Yast::Logger
- Defined in:
- src/lib/y2packager/resolvable.rb
Overview
The returned Resolvables might not be valid anymore after changing the package manager status (installing/removing packages, changing repositories, etc.). After such a change you need to load the resolvables again, avoid storing them for later if possible.
This class represents a libzypp resolvable object (package, pattern, patch, product, source package)
Class Method Summary collapse
-
.any?(params) ⇒ Boolean
Is there any resolvable matching the requested parameters? This is similar to the .find method, just instead of a resolvable list it returns a simple Boolean.
-
.find(params, preload = []) ⇒ Array<Y2Packager::Resolvable>
Find the resolvables which match the input parameters.
Instance Method Summary collapse
-
#initialize(hash) ⇒ Resolvable
constructor
Constructor, initialize the object from a pkg-bindings resolvable hash.
-
#method_missing(method, *args) ⇒ Object
Dynamically load the missing attributes from libzypp.
Constructor Details
#initialize(hash) ⇒ Resolvable
Constructor, initialize the object from a pkg-bindings resolvable hash.
79 80 81 |
# File 'src/lib/y2packager/resolvable.rb', line 79 def initialize(hash) from_hash(hash) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
Dynamically load the missing attributes from libzypp.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'src/lib/y2packager/resolvable.rb', line 91 def method_missing(method, *args) if instance_variable_defined?("@#{method}") raise ArgumentError, "Method #{method} does not accept arguments" unless args.empty? return instance_variable_get("@#{method}") end # load a missing attribute if UNIQUE_ATTRIBUTES.all? { |a| instance_variable_defined?("@#{a}") } load_attribute(method) super unless instance_variable_defined?("@#{method}") raise ArgumentError, "Method #{method} does not accept arguments" unless args.empty? instance_variable_get("@#{method}") else raise "Missing attributes for identifying the resolvable." end end |
Class Method Details
.any?(params) ⇒ Boolean
Is there any resolvable matching the requested parameters? This is similar to the .find method, just instead of a resolvable list it returns a simple Boolean.
71 72 73 |
# File 'src/lib/y2packager/resolvable.rb', line 71 def self.any?(params) Yast::Pkg.AnyResolvable(params) end |
.find(params, preload = []) ⇒ Array<Y2Packager::Resolvable>
Find the resolvables which match the input parameters. See Yast::Pkg.Resolvables
59 60 61 62 |
# File 'src/lib/y2packager/resolvable.rb', line 59 def self.find(params, preload = []) attrs = (preload + UNIQUE_ATTRIBUTES).uniq Yast::Pkg.Resolvables(params, attrs).map { |r| new(r) } end |