Module: PropertySets::PropertySetModel::InstanceMethods

Defined in:
lib/property_sets/property_set_model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#value_serializedObject

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

#disableObject


31
32
33
34
# File 'lib/property_sets/property_set_model.rb', line 31

def disable
  update_attribute(:value, "0")
  self
end

#enableObject


26
27
28
29
# File 'lib/property_sets/property_set_model.rb', line 26

def enable
  update_attribute(:value, "1")
  self
end

#false?Boolean

Returns:

  • (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

Returns:

  • (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_sObject


63
64
65
# File 'lib/property_sets/property_set_model.rb', line 63

def to_s
  value.to_s
end

#true?Boolean

Returns:

  • (Boolean)

22
23
24
# File 'lib/property_sets/property_set_model.rb', line 22

def true?
  !false?
end

#valueObject


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(v)
  end
end