Module: PropertySets::PropertySetModel::InstanceMethods
- Defined in:
- lib/property_sets/property_set_model.rb
Instance Attribute Summary collapse
-
#value_serialized ⇒ Object
Returns the value of attribute value_serialized.
Instance Method Summary collapse
- #disable ⇒ Object
- #enable ⇒ Object
- #false? ⇒ Boolean
- #protected? ⇒ Boolean
- #reload(*args, &block) ⇒ Object
- #to_s ⇒ Object
- #true? ⇒ Boolean
- #value ⇒ Object
- #value=(v) ⇒ Object
Instance Attribute Details
#value_serialized ⇒ Object
Returns the value of attribute value_serialized.
67 68 69 |
# File 'lib/property_sets/property_set_model.rb', line 67 def value_serialized @value_serialized end |
Instance Method Details
#disable ⇒ Object
31 32 33 34 |
# File 'lib/property_sets/property_set_model.rb', line 31 def disable update_attribute(:value, "0") self end |
#enable ⇒ Object
26 27 28 29 |
# File 'lib/property_sets/property_set_model.rb', line 26 def enable update_attribute(:value, "1") self end |
#false? ⇒ Boolean
18 19 20 |
# File 'lib/property_sets/property_set_model.rb', line 18 def false? ["false", "0", "", "off", "n"].member?(value.to_s.downcase) end |
#protected? ⇒ Boolean
36 37 38 |
# File 'lib/property_sets/property_set_model.rb', line 36 def protected? self.class.protected?(name.to_sym) end |
#reload(*args, &block) ⇒ Object
58 59 60 61 |
# File 'lib/property_sets/property_set_model.rb', line 58 def reload(*args, &block) @deserialized_value = nil super end |
#to_s ⇒ Object
63 64 65 |
# File 'lib/property_sets/property_set_model.rb', line 63 def to_s value.to_s end |
#true? ⇒ Boolean
22 23 24 |
# File 'lib/property_sets/property_set_model.rb', line 22 def true? !false? end |
#value ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/property_sets/property_set_model.rb', line 40 def value if value_serialized v = read_attribute(:value) @deserialized_value ||= PropertySets::Casting.deserialize(v) else super end end |
#value=(v) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/property_sets/property_set_model.rb', line 49 def value=(v) if value_serialized @deserialized_value = v write_attribute(:value, v.to_json) else super end end |