pseudo_entity 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pseudo_entity.rb +10 -0
- data/lib/pseudo_entity/version.rb +1 -1
- data/spec/lib/pseudo_entity_spec.rb +23 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed330667433de06f720edbf6c5521158da50a187
|
4
|
+
data.tar.gz: f6fa6936cf78078cb624047f74015c1cb97dc0bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce9ad2fc3efb2fa8019a202933c87e9c03c034e3df2795dad22f9f35e4c43e4d1f1bce2535572560882a0df9e7050ec55be617016d609660bebc6be12c58176e
|
7
|
+
data.tar.gz: 379cf79c9cda5989f52eaaa5067d906bfeb99196a03a2943b332d96e3b184b37adf1cfbc02eb989770c83d48fc8c02e494483a6ff0f16d6db48fb8bc271e4a84
|
data/lib/pseudo_entity.rb
CHANGED
@@ -44,6 +44,16 @@ class PseudoEntity
|
|
44
44
|
self
|
45
45
|
end
|
46
46
|
|
47
|
+
def reset(value_name)
|
48
|
+
value_name = value_name.to_s.to_sym
|
49
|
+
if self.respond_to?(value_name)
|
50
|
+
instance_variable_set("@#{value_name}".to_sym, nil)
|
51
|
+
self.send(value_name)
|
52
|
+
else
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
47
57
|
def street_address
|
48
58
|
# Yes it is in 2-1 order because that's how the US Post Office says to do it.
|
49
59
|
# Apartment, Suites, etc go on the first line if there are two lines or at the end of the single line
|
@@ -65,26 +65,41 @@ describe PseudoEntity do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should not return new values without resetting" do
|
68
|
-
names = [ 'Jack', 'Jill' ]
|
69
68
|
pseudo_entity = PseudoEntity.new
|
70
|
-
pseudo_entity.
|
71
|
-
pseudo_entity.first_name.should equal(
|
69
|
+
first_name = pseudo_entity.first_name
|
70
|
+
pseudo_entity.first_name.should equal(first_name)
|
72
71
|
end
|
73
72
|
|
74
73
|
it "should return new values after a reset" do
|
75
|
-
names = [ 'Jack', 'Jill' ]
|
76
74
|
pseudo_entity = PseudoEntity.new
|
77
|
-
pseudo_entity.
|
78
|
-
|
75
|
+
first_name = pseudo_entity.first_name
|
76
|
+
last_name = pseudo_entity.last_name
|
79
77
|
pseudo_entity.reset!
|
80
|
-
pseudo_entity.
|
81
|
-
pseudo_entity.
|
78
|
+
pseudo_entity.first_name.should_not eql(first_name)
|
79
|
+
pseudo_entity.last_name.should_not eql(last_name)
|
82
80
|
end
|
83
81
|
|
84
82
|
it "should return self after a reset" do
|
85
83
|
pseudo_entity.reset!.should equal(pseudo_entity)
|
86
84
|
end
|
87
85
|
|
86
|
+
it "should reset a single value" do
|
87
|
+
pseudo_entity = PseudoEntity.new
|
88
|
+
first_name = pseudo_entity.first_name
|
89
|
+
last_name = pseudo_entity.last_name
|
90
|
+
pseudo_entity.reset("first_name")
|
91
|
+
pseudo_entity.first_name.should_not eql(first_name)
|
92
|
+
pseudo_entity.last_name.should eql(last_name)
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should return the new value after a reset of a single value" do
|
96
|
+
pseudo_entity = PseudoEntity.new
|
97
|
+
first_name_a = pseudo_entity.first_name
|
98
|
+
first_name_b = pseudo_entity.reset("first_name")
|
99
|
+
first_name_a.should_not eql(first_name_b)
|
100
|
+
first_name_b.should eql(pseudo_entity.first_name)
|
101
|
+
end
|
102
|
+
|
88
103
|
it "should combine addresses in 2,1 order" do
|
89
104
|
pseudo_entity.stub(:street_address_line_1).and_return(:street_address_line_1)
|
90
105
|
pseudo_entity.stub(:street_address_line_2).and_return(:street_address_line_2)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pseudo_entity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank Hall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|