Skip to content

Instantly share code, notes, and snippets.

@benphelps
Created August 29, 2012 14:56
Show Gist options
  • Save benphelps/3513837 to your computer and use it in GitHub Desktop.
Save benphelps/3513837 to your computer and use it in GitHub Desktop.
class ArmorItem < ActiveRecord::Base
attr_accessible :armor_tier_id, :bonus_id, :enchant_id, :name, :stat_set_id
belongs_to :armor_tier
belongs_to :enchant
belongs_to :bonus
belongs_to :stat_set
def stat
StatSet.find(stat_set_id)
end
[:agility, :stamina, :strength, :intellect].each do |stat|
define_method stat do
armor_tier.stat.send(stat) + stat_set.send(stat)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment