Delete unused PetAttribute model files
Oh right, this powered `Color` and `Species` back before they were database rows. Now these base classes are unused! Goodbye!
This commit is contained in:
parent
99f5cd717f
commit
c8de3dae63
2 changed files with 0 additions and 80 deletions
|
@ -1,55 +0,0 @@
|
|||
class PetAttribute < StaticResource
|
||||
def as_json(options={})
|
||||
{
|
||||
:id => self.id,
|
||||
:name => self.human_name
|
||||
}
|
||||
end
|
||||
|
||||
def human_name
|
||||
@human_name ||= self.name.split(' ').each { |word| word.capitalize! }.join(' ')
|
||||
end
|
||||
|
||||
class << self
|
||||
def all_ordered_by_name
|
||||
@objects_ordered_by_name
|
||||
end
|
||||
|
||||
def find(id)
|
||||
attribute = super
|
||||
unless attribute
|
||||
attribute = new
|
||||
attribute.id = id
|
||||
attribute.name = "color \##{id}"
|
||||
end
|
||||
attribute
|
||||
end
|
||||
|
||||
def find_by_name(name)
|
||||
@objects_by_name[name.downcase]
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.data_source
|
||||
"#{to_s.downcase.pluralize}.txt"
|
||||
end
|
||||
|
||||
def self.process_line(line)
|
||||
name = line.chomp.downcase
|
||||
@objects << @objects_by_name[name] = species = new
|
||||
species.id = @objects.size
|
||||
species.name = name
|
||||
end
|
||||
|
||||
def self.fetch_objects!
|
||||
@objects = []
|
||||
@objects_by_name = {}
|
||||
File.open(Rails.root.join('config', data_source)).each do |line|
|
||||
process_line(line)
|
||||
end
|
||||
@objects_ordered_by_name = @objects.sort { |a,b| a.name <=> b.name }
|
||||
end
|
||||
end
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
class StaticResource
|
||||
attr_accessor :id, :name
|
||||
|
||||
def self.all
|
||||
@objects
|
||||
end
|
||||
|
||||
def self.find(id_or_ids)
|
||||
if id_or_ids.is_a?(Array)
|
||||
id_or_ids.uniq.map { |id| find_one(id) }
|
||||
else
|
||||
find_one(id_or_ids)
|
||||
end
|
||||
end
|
||||
|
||||
def self.count
|
||||
@objects.size
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.find_one(id)
|
||||
@objects[id - 1]
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue