Class: Kiba::Extend::Registry::RegistryEntrySelector
- Inherits:
-
Object
- Object
- Kiba::Extend::Registry::RegistryEntrySelector
- Defined in:
- lib/kiba/extend/registry/registry_entry_selector.rb
Overview
Used in Rake tasks in project application to identify particular files/jobs to run or display information about
Instance Method Summary collapse
-
#created_by_class(cstr) ⇒ Array<FileRegistryEntry>
Registry entries created by a given class.
-
#created_by_method(mstr) ⇒ Array<FileRegistryEntry>
Registry entry or entries created by a given method.
-
#tagged_all(*args) ⇒ Array<FileRegistryEntry>
Selects entries whose tags include all given tags.
-
#tagged_any(*args) ⇒ Array<FileRegistryEntry>
Selects entries whose tags include one or more of the given tags.
Instance Method Details
#created_by_class(cstr) ⇒ Array<FileRegistryEntry>
Registry entries created by a given class
14 15 16 |
# File 'lib/kiba/extend/registry/registry_entry_selector.rb', line 14 def created_by_class(cstr) with_creator.select { |entry| entry.creator.mod.to_s[cstr] } end |
#created_by_method(mstr) ⇒ Array<FileRegistryEntry>
Registry entry or entries created by a given method
21 22 23 24 |
# File 'lib/kiba/extend/registry/registry_entry_selector.rb', line 21 def created_by_method(mstr) matcher = "#<Method: #{mstr}(" with_creator.select { |entry| entry.creator.to_s[matcher] } end |
#tagged_all(*args) ⇒ Array<FileRegistryEntry>
Selects entries whose tags include all given tags
29 30 31 32 33 34 |
# File 'lib/kiba/extend/registry/registry_entry_selector.rb', line 29 def tagged_all(*args) = args.flatten.map(&:to_sym) .inject(Kiba::Extend.registry.entries) do |arr, tag| arr.select { |entry| entry..any?(tag) } end end |
#tagged_any(*args) ⇒ Array<FileRegistryEntry>
Selects entries whose tags include one or more of the given tags
39 40 41 42 43 44 45 |
# File 'lib/kiba/extend/registry/registry_entry_selector.rb', line 39 def tagged_any(*args) = args.flatten.map(&:to_sym) results = .each_with_object([]) do |arg, arr| arr << tagged(arg) end results.flatten.uniq end |