Juicy Code

Open Source

2012/01/23

Categories: Code Tags: Juicy

Check out this JUICY! code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
def with_value_from_database(value)
  self.class.from_database(name, value, type)
end

def with_cast_value(value)
  self.class.with_cast_value(name, value, type)
end

def with_type(type)
  if changed_in_place?
    with_value_from_user(value).with_type(type)
  else
    self.class.new(name, value_before_type_cast, type, original_attribute)
  end
end