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.



56
57
58
# File 'lib/property_sets/property_set_model.rb', line 56

def value_serialized
  @value_serialized
end

Instance Method Details

#disableObject



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

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

#enableObject



15
16
17
18
# File 'lib/property_sets/property_set_model.rb', line 15

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

#false?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/property_sets/property_set_model.rb', line 7

def false?
  [ "false", "0", "", "off", "n" ].member?(value.to_s.downcase)
end

#protected?Boolean

Returns:

  • (Boolean)


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

def protected?
  self.class.protected?(name.to_sym)
end

#reload(*args, &block) ⇒ Object



47
48
49
50
# File 'lib/property_sets/property_set_model.rb', line 47

def reload(*args, &block)
  @deserialized_value = nil
  super
end

#to_sObject



52
53
54
# File 'lib/property_sets/property_set_model.rb', line 52

def to_s
  value.to_s
end

#true?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/property_sets/property_set_model.rb', line 11

def true?
  !false?
end

#valueObject



29
30
31
32
33
34
35
36
# File 'lib/property_sets/property_set_model.rb', line 29

def value
  if value_serialized
    v = read_attribute(:value)
    @deserialized_value ||= PropertySets::Casting.deserialize(v)
  else
    super
  end
end

#value=(v) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/property_sets/property_set_model.rb', line 38

def value=(v)
  if value_serialized
    @deserialized_value = v
    write_attribute(:value, v.to_json)
  else
    super(v)
  end
end