Class: ModelScope::Collector
- Inherits:
-
Object
- Object
- ModelScope::Collector
- Defined in:
- lib/modelscope/collector.rb
Instance Attribute Summary collapse
-
#models ⇒ Object
readonly
Returns the value of attribute models.
Instance Method Summary collapse
- #collect ⇒ Object
-
#initialize(models = nil, paths: nil, kind: :callbacks) ⇒ Collector
constructor
A new instance of Collector.
Constructor Details
#initialize(models = nil, paths: nil, kind: :callbacks) ⇒ Collector
Returns a new instance of Collector.
9 10 11 12 13 14 15 |
# File 'lib/modelscope/collector.rb', line 9 def initialize(models = nil, paths: nil, kind: :callbacks) @paths = paths @kind = kind eager_load! @models = Set.new(models ? [*models] : ApplicationRecord.descendants) end |
Instance Attribute Details
#models ⇒ Object (readonly)
Returns the value of attribute models.
7 8 9 |
# File 'lib/modelscope/collector.rb', line 7 def models @models end |
Instance Method Details
#collect ⇒ Object
17 18 19 |
# File 'lib/modelscope/collector.rb', line 17 def collect models.flat_map { |model| collect_for_model(model) } end |