virtus 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -167,7 +167,7 @@ module Virtus
167
167
  # @api private
168
168
  def set(model, value)
169
169
  return if value.nil?
170
- set!(model, primitive?(value) ? value : typecast(value, model))
170
+ set!(model, typecast(value, model))
171
171
  end
172
172
 
173
173
  # Sets instance variable of the attribute
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe Virtus::Attributes::Attribute, '#typecast' do
4
+ let(:attribute_class) do
5
+ Class.new(Virtus::Attributes::Integer) do
6
+ def typecast(value, object)
7
+ super + 1
8
+ end
9
+ end
10
+ end
11
+
12
+ let(:model) do
13
+ model = Class.new do
14
+ include Virtus
15
+ end
16
+ model.attribute(:count, attribute_class)
17
+ model
18
+ end
19
+
20
+ let(:object) do
21
+ model.new
22
+ end
23
+
24
+ context 'when overridden' do
25
+ let(:input_value) { 1 }
26
+ let(:output_value) { 2 }
27
+
28
+ before do
29
+ object.count = input_value
30
+ end
31
+
32
+ it "peforms custom typecasting" do
33
+ object.count.should == output_value
34
+ end
35
+ end
36
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{virtus}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Piotr Solnica}]
12
- s.date = %q{2011-06-04}
12
+ s.date = %q{2011-06-06}
13
13
  s.description = %q{Attributes for your plain ruby objects}
14
14
  s.email = [%q{piotr@rubyverse.com}]
15
15
  s.extra_rdoc_files = [
@@ -44,6 +44,7 @@ Gem::Specification.new do |s|
44
44
  "lib/virtus/class_methods.rb",
45
45
  "lib/virtus/instance_methods.rb",
46
46
  "lib/virtus/support/chainable.rb",
47
+ "spec/integration/virtus/attributes/attribute/typecast_spec.rb",
47
48
  "spec/integration/virtus/class_methods/attribute_spec.rb",
48
49
  "spec/integration/virtus/class_methods/attributes_spec.rb",
49
50
  "spec/integration/virtus/class_methods/const_missing_spec.rb",
metadata CHANGED
@@ -1,58 +1,61 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: virtus
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.1
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
5
+ version: 0.0.2
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Piotr Solnica
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-06-04 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
12
+
13
+ date: 2011-06-06 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
15
16
  name: jeweler
16
- requirement: &76569310 !ruby/object:Gem::Requirement
17
+ requirement: &id001 !ruby/object:Gem::Requirement
17
18
  none: false
18
- requirements:
19
+ requirements:
19
20
  - - ~>
20
- - !ruby/object:Gem::Version
21
+ - !ruby/object:Gem::Version
21
22
  version: 1.5.2
22
23
  type: :development
23
24
  prerelease: false
24
- version_requirements: *76569310
25
- - !ruby/object:Gem::Dependency
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
26
27
  name: rspec
27
- requirement: &76569070 !ruby/object:Gem::Requirement
28
+ requirement: &id002 !ruby/object:Gem::Requirement
28
29
  none: false
29
- requirements:
30
+ requirements:
30
31
  - - ~>
31
- - !ruby/object:Gem::Version
32
+ - !ruby/object:Gem::Version
32
33
  version: 2.6.0
33
34
  type: :development
34
35
  prerelease: false
35
- version_requirements: *76569070
36
- - !ruby/object:Gem::Dependency
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
37
38
  name: simplecov
38
- requirement: &76568830 !ruby/object:Gem::Requirement
39
+ requirement: &id003 !ruby/object:Gem::Requirement
39
40
  none: false
40
- requirements:
41
+ requirements:
41
42
  - - ~>
42
- - !ruby/object:Gem::Version
43
+ - !ruby/object:Gem::Version
43
44
  version: 0.4.2
44
45
  type: :development
45
46
  prerelease: false
46
- version_requirements: *76568830
47
+ version_requirements: *id003
47
48
  description: Attributes for your plain ruby objects
48
- email:
49
+ email:
49
50
  - piotr@rubyverse.com
50
51
  executables: []
52
+
51
53
  extensions: []
52
- extra_rdoc_files:
54
+
55
+ extra_rdoc_files:
53
56
  - LICENSE
54
57
  - README.markdown
55
- files:
58
+ files:
56
59
  - .gitignore
57
60
  - .rvmrc
58
61
  - .travis.yml
@@ -80,6 +83,7 @@ files:
80
83
  - lib/virtus/class_methods.rb
81
84
  - lib/virtus/instance_methods.rb
82
85
  - lib/virtus/support/chainable.rb
86
+ - spec/integration/virtus/attributes/attribute/typecast_spec.rb
83
87
  - spec/integration/virtus/class_methods/attribute_spec.rb
84
88
  - spec/integration/virtus/class_methods/attributes_spec.rb
85
89
  - spec/integration/virtus/class_methods/const_missing_spec.rb
@@ -106,26 +110,30 @@ files:
106
110
  - virtus.gemspec
107
111
  homepage: https://github.com/solnic/virtus
108
112
  licenses: []
113
+
109
114
  post_install_message:
110
115
  rdoc_options: []
111
- require_paths:
116
+
117
+ require_paths:
112
118
  - lib
113
- required_ruby_version: !ruby/object:Gem::Requirement
119
+ required_ruby_version: !ruby/object:Gem::Requirement
114
120
  none: false
115
- requirements:
116
- - - ! '>='
117
- - !ruby/object:Gem::Version
118
- version: '0'
119
- required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: "0"
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
126
  none: false
121
- requirements:
122
- - - ! '>='
123
- - !ruby/object:Gem::Version
124
- version: '0'
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: "0"
125
131
  requirements: []
132
+
126
133
  rubyforge_project:
127
134
  rubygems_version: 1.8.5
128
135
  signing_key:
129
136
  specification_version: 3
130
137
  summary: Attributes for your plain ruby objects
131
138
  test_files: []
139
+