Class: Stratify::Collector
- Inherits:
-
Object
- Object
- Stratify::Collector
- Includes:
- Mongoid::Document
- Defined in:
- lib/stratify/collector.rb
Class Attribute Summary collapse
-
.collector_classes ⇒ Object
readonly
Returns the value of attribute collector_classes.
Class Method Summary collapse
- .collector_class_for(source) ⇒ Object
- .configuration_fields(fields_hash = nil) ⇒ Object
- .configuration_instructions(instructions = nil) ⇒ Object
- .inherited(subclass) ⇒ Object
-
.source(src = nil) ⇒ Object
Define where this collector’s activities originate from (e.g., “Twitter”, “iTunes”).
- .sources ⇒ Object
Instance Method Summary collapse
-
#activities ⇒ Object
To be implemented by subclasses.
- #configuration_fields ⇒ Object
- #configuration_instructions ⇒ Object
- #configuration_summary ⇒ Object
- #run ⇒ Object
- #source ⇒ Object
Class Attribute Details
.collector_classes ⇒ Object (readonly)
Returns the value of attribute collector_classes.
63 64 65 |
# File 'lib/stratify/collector.rb', line 63 def collector_classes @collector_classes end |
Class Method Details
.collector_class_for(source) ⇒ Object
73 74 75 |
# File 'lib/stratify/collector.rb', line 73 def self.collector_class_for(source) Collector.collector_classes.find {|clazz| clazz.source == source} end |
.configuration_fields(fields_hash = nil) ⇒ Object
13 14 15 16 |
# File 'lib/stratify/collector.rb', line 13 def self.configuration_fields(fields_hash = nil) @configuration_fields = initialize_configuration_fields(fields_hash) unless fields_hash.nil? @configuration_fields || [] end |
.configuration_instructions(instructions = nil) ⇒ Object
22 23 24 25 |
# File 'lib/stratify/collector.rb', line 22 def self.configuration_instructions(instructions = nil) @configuration_instructions = instructions unless instructions.nil? @configuration_instructions end |
.inherited(subclass) ⇒ Object
68 69 70 71 |
# File 'lib/stratify/collector.rb', line 68 def self.inherited(subclass) super Collector.collector_classes << subclass end |
.source(src = nil) ⇒ Object
Define where this collector’s activities originate from (e.g., “Twitter”, “iTunes”)
48 49 50 51 |
# File 'lib/stratify/collector.rb', line 48 def self.source(src = nil) @source = src unless src.nil? @source end |
.sources ⇒ Object
57 58 59 60 |
# File 'lib/stratify/collector.rb', line 57 def self.sources unsorted_sources = Collector.collector_classes.map(&:source) unsorted_sources.sort_by {|source| source.downcase} end |
Instance Method Details
#activities ⇒ Object
To be implemented by subclasses
Returns a collection of activities to be saved.
43 44 45 |
# File 'lib/stratify/collector.rb', line 43 def activities raise NotImplementedError end |
#configuration_fields ⇒ Object
18 19 20 |
# File 'lib/stratify/collector.rb', line 18 def configuration_fields self.class.configuration_fields end |
#configuration_instructions ⇒ Object
27 28 29 |
# File 'lib/stratify/collector.rb', line 27 def configuration_instructions self.class.configuration_instructions end |
#configuration_summary ⇒ Object
31 32 33 34 |
# File 'lib/stratify/collector.rb', line 31 def configuration_summary return nil if configuration_fields.empty? read_attribute(configuration_fields.first.name) end |
#run ⇒ Object
36 37 38 |
# File 'lib/stratify/collector.rb', line 36 def run Archiver.new(self).run end |
#source ⇒ Object
53 54 55 |
# File 'lib/stratify/collector.rb', line 53 def source self.class.source end |