valuable 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,6 +2,7 @@
2
2
  *.swp
3
3
  .bundle
4
4
  .rvmrc
5
+ .rbx
5
6
  .irbrc
6
7
  .svn
7
8
  pkg
@@ -94,6 +94,8 @@ module Valuable::Utils
94
94
  nil
95
95
  elsif value.is_a? klass
96
96
  value
97
+ elsif Proc === attributes[name][:parse_with]
98
+ attributes[name][:parse_with].call(value)
97
99
  else
98
100
  klass.send( attributes[name][:parse_with] || :new, value)
99
101
  end
@@ -18,6 +18,7 @@ class RailsApp < Valuable
18
18
  has_value :tech_lead, :klass => Person, :parse_with => :load
19
19
  has_collection :devs, :klass => Person, :parse_with => :load
20
20
  has_value :name, :parse_with => lambda{|x| x == 'IA' ? 'Information Architecture' : x}
21
+ has_value :overlord, :klass => Person, :parse_with => lambda{|name| Person.load(name) }
21
22
  end
22
23
 
23
24
  class ParseWithTest < Test::Unit::TestCase
@@ -44,4 +45,8 @@ class ParseWithTest < Test::Unit::TestCase
44
45
  animal.has_value :invalid, :klass => :integer, :parse_with => :method
45
46
  end
46
47
  end
48
+
49
+ def test_that_lambdas_can_be_combined_with_a_class
50
+ assert_equal 'vader', RailsApp.new(:overlord => 'darth vader').overlord.last_name
51
+ end
47
52
  end
data/valuable.version CHANGED
@@ -1 +1 @@
1
- 0.9.4
1
+ 0.9.5
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valuable
3
3
  version: !ruby/object:Gem::Version
4
- hash: 51
4
+ hash: 49
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 4
10
- version: 0.9.4
9
+ - 5
10
+ version: 0.9.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Johnathon Wright
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-10 00:00:00 -05:00
18
+ date: 2012-05-08 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies: []
21
21