Class: QueryPackwerk::Packages
- Inherits:
-
Object
- Object
- QueryPackwerk::Packages
- Extended by:
- T::Generic, T::Sig
- Includes:
- Enumerable, QueryInterface
- Defined in:
- lib/query_packwerk/packages.rb
Overview
A collection class for managing and querying sets of Packwerk packages. Provides methods for retrieving, filtering, and analyzing packages within the application. Implements Enumerable and QueryInterface for flexible data manipulation and consistent query patterns.
Constant Summary collapse
- Elem =
type_member { { fixed: QueryPackwerk::Package } }
- UNOWNED =
T.let('Unowned', String)
Instance Attribute Summary collapse
-
#original_collection ⇒ Object
readonly
Returns the value of attribute original_collection.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(original_collection) ⇒ Packages
constructor
A new instance of Packages.
- #inspect ⇒ Object
- #violations ⇒ Object
Methods included from QueryInterface
Constructor Details
#initialize(original_collection) ⇒ Packages
Returns a new instance of Packages.
55 56 57 |
# File 'lib/query_packwerk/packages.rb', line 55 def initialize(original_collection) @original_collection = original_collection end |
Instance Attribute Details
#original_collection ⇒ Object (readonly)
Returns the value of attribute original_collection.
21 22 23 |
# File 'lib/query_packwerk/packages.rb', line 21 def original_collection @original_collection end |
Class Method Details
.all ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/query_packwerk/packages.rb', line 28 def all @all ||= T.let( begin packages = ParsePackwerk.all.map { |p| QueryPackwerk::Package.new(original_package: p) } QueryPackwerk::Packages.new(packages) end, T.nilable(QueryPackwerk::Packages) ) end |
.reload! ⇒ Object
49 50 51 |
# File 'lib/query_packwerk/packages.rb', line 49 def reload! @all = nil end |
.where(**query_params, &query_fn) ⇒ Object
44 45 46 |
# File 'lib/query_packwerk/packages.rb', line 44 def where(**query_params, &query_fn) QueryPackwerk::Packages.new(super) end |
Instance Method Details
#inspect ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/query_packwerk/packages.rb', line 70 def inspect [ "#<#{self.class.name} [", to_a.map(&:inspect).join("\n"), ']>' ].join("\n") end |
#violations ⇒ Object
63 64 65 66 67 |
# File 'lib/query_packwerk/packages.rb', line 63 def violations QueryPackwerk::Violations.new( @original_collection.flat_map { |pack| pack.violations.original_collection } ) end |