summaryrefslogtreecommitdiff
path: root/themes/hugo-classic/exampleSite/content/post/2012-01-23-juicy-code.md
blob: 4614e74a407fdbf543c3eef41a474579ab4a2e26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
---
title: Juicy Code
author: Open Source
date: '2012-01-23'
categories:
  - Code
tags:
  - Juicy
slug: juicy-code
---

Check out this JUICY! code:

~~~ruby
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
~~~