Module: Dunlop::TargetFileModel::ClassMethods
- Defined in:
- app/models/dunlop/target_file_model.rb
Instance Method Summary collapse
- #activate_dunlop! ⇒ Object
- #class_names ⇒ Object
- #classes ⇒ Object
- #completed ⇒ Object
- #factory(attrs) ⇒ Object
- #latest ⇒ Object
- #setup_target_files(target_file_names) ⇒ Object
- #target_file_names ⇒ Object
Instance Method Details
#activate_dunlop! ⇒ Object
172 173 |
# File 'app/models/dunlop/target_file_model.rb', line 172 def activate_dunlop! end |
#class_names ⇒ Object
152 153 154 |
# File 'app/models/dunlop/target_file_model.rb', line 152 def class_names target_file_names.map{|tfn| "TargetFile::#{tfn.to_s.classify}"} end |
#classes ⇒ Object
148 149 150 |
# File 'app/models/dunlop/target_file_model.rb', line 148 def classes @classes ||= class_names.map(&:constantize) end |
#completed ⇒ Object
168 169 170 |
# File 'app/models/dunlop/target_file_model.rb', line 168 def completed where(state: 'completed') end |
#factory(attrs) ⇒ Object
142 143 144 145 146 |
# File 'app/models/dunlop/target_file_model.rb', line 142 def factory(attrs) attrs ||= {} klass = classes.find { |c| c.to_s == attrs[:sti_type].to_s } || self klass.new(attrs) end |
#latest ⇒ Object
164 165 166 |
# File 'app/models/dunlop/target_file_model.rb', line 164 def latest completed.last end |
#setup_target_files(target_file_names) ⇒ Object
156 157 158 |
# File 'app/models/dunlop/target_file_model.rb', line 156 def setup_target_files(target_file_names) @target_file_names = target_file_names end |
#target_file_names ⇒ Object
160 161 162 |
# File 'app/models/dunlop/target_file_model.rb', line 160 def target_file_names @target_file_names end |