Class: Spree::Preference
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spree::Preference
- Defined in:
- app/models/spree/preference.rb
Instance Method Summary collapse
- #raw_value ⇒ Object
-
#value ⇒ Object
The type conversions here should match the ones in spree::preferences::preferrable#convert_preference_value.
Instance Method Details
#raw_value ⇒ Object
32 33 34 |
# File 'app/models/spree/preference.rb', line 32 def raw_value self[:value] end |
#value ⇒ Object
The type conversions here should match the ones in spree::preferences::preferrable#convert_preference_value
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/models/spree/preference.rb', line 11 def value if self[:value_type].present? case self[:value_type].to_sym when :string, :text self[:value].to_s when :password self[:value].to_s when :decimal BigDecimal.new(self[:value].to_s).round(2, BigDecimal::ROUND_HALF_UP) when :integer self[:value].to_i when :boolean (self[:value].to_s =~ /^[t|1]/i) != nil else self[:value].is_a?(String) ? YAML.load(self[:value]) : self[:value] end else self[:value] end end |