Module: Dunlop::TargetFileModel::ClassMethods

Defined in:
app/models/dunlop/target_file_model.rb

Instance Method Summary collapse

Instance Method Details

#activate_dunlop!Object



172
173
# File 'app/models/dunlop/target_file_model.rb', line 172

def activate_dunlop!
end

#class_namesObject



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

#classesObject



148
149
150
# File 'app/models/dunlop/target_file_model.rb', line 148

def classes
  @classes ||= class_names.map(&:constantize)
end

#completedObject



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

#latestObject



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_namesObject



160
161
162
# File 'app/models/dunlop/target_file_model.rb', line 160

def target_file_names
  @target_file_names
end