Class: Optimizable::Optimization
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Optimizable::Optimization
- Defined in:
- app/models/optimizable/optimization.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.for(optimizable) ⇒ Object
8 9 10 |
# File 'app/models/optimizable/optimization.rb', line 8 def self.for(optimizable) self.where(:optimizable_id => optimizable.id, :optimizable_type => optimizable.class.to_s).first end |
Instance Method Details
#after_initialize ⇒ Object
12 13 14 15 16 17 |
# File 'app/models/optimizable/optimization.rb', line 12 def after_initialize self.data ||= {} Optimizable..each do |option| self.data[option] = nil end end |
#get(key) ⇒ Object
19 20 21 |
# File 'app/models/optimizable/optimization.rb', line 19 def get key self.data[key] end |
#human_optimizable ⇒ Object
23 24 25 |
# File 'app/models/optimizable/optimization.rb', line 23 def human_optimizable [optimizable.try(:title) || optimizable.try(:name) || optimizable.try(:id), optimizable.class.to_s].join(' ').downcase end |