Class: Drudgery::Extractors::ActiveRecordExtractor
- Inherits:
-
Object
- Object
- Drudgery::Extractors::ActiveRecordExtractor
- Defined in:
- lib/drudgery/extractors/active_record_extractor.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #extract ⇒ Object
-
#initialize(model) ⇒ ActiveRecordExtractor
constructor
A new instance of ActiveRecordExtractor.
- #record_count ⇒ Object
Constructor Details
#initialize(model) ⇒ ActiveRecordExtractor
Returns a new instance of ActiveRecordExtractor.
6 7 8 9 |
# File 'lib/drudgery/extractors/active_record_extractor.rb', line 6 def initialize(model) @model = model @name = "active_record:#{@model.name}" end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/drudgery/extractors/active_record_extractor.rb', line 4 def name @name end |
Instance Method Details
#extract ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/drudgery/extractors/active_record_extractor.rb', line 11 def extract index = 0 @model.find_each do |record| yield [record.attributes, index] index += 1 end end |
#record_count ⇒ Object
21 22 23 |
# File 'lib/drudgery/extractors/active_record_extractor.rb', line 21 def record_count @record_count ||= @model.count end |