Module: Preferable::Model::ClassMethods
- Defined in:
- lib/preferable/model.rb
Instance Method Summary collapse
-
#preferable(&block) ⇒ Object
Preferable definition for a model.
Instance Method Details
#preferable(&block) ⇒ Object
Preferable definition for a model. Example:
class User < ActiveRecord::Base
preferable do
integer :theme_id
boolean :accessible, :default => false
string :font_color, :default => "444444", :if => lambda {|value| value =~ /^[A-F0-9]{6}$/ }
end
end
23 24 25 26 27 28 29 30 |
# File 'lib/preferable/model.rb', line 23 def preferable(&block) serialize :preferences, Preferable::Coder.new include PreferableMethods self._preferable = self._preferable.dup if self._preferable self._preferable ||= Preferable::Schema.new self._preferable.instance_eval(&block) end |