mozart 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,6 +15,10 @@ module Mozart
15
15
  self.class == other.class && __data__ == other.__data__
16
16
  end
17
17
 
18
+ def to_hash
19
+ Marshal.load(Marshal.dump(__data__))
20
+ end
21
+
18
22
  alias_method :eql?, :==
19
23
 
20
24
  def hash
@@ -22,7 +26,8 @@ module Mozart
22
26
  end
23
27
 
24
28
  field_names.each do |name|
25
- define_method(name) { __data__[name] }
29
+ define_method(name) { __data__[name] }
30
+ define_method("#{name}=") { |value| __data__[name] = value }
26
31
  end
27
32
 
28
33
  protected
@@ -1,3 +1,3 @@
1
1
  module Mozart
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -8,6 +8,17 @@ describe "Mozart.value" do
8
8
  pos1 = pos_builder.new(:x => 10, :y => 20)
9
9
  pos1.x.must_equal(10)
10
10
  pos1.y.must_equal(20)
11
+
12
+ pos1.x = 20
13
+ pos1.x.must_equal(20)
14
+ end
15
+
16
+ it "can be converted into a Hash object" do
17
+ pos_builder = Mozart.value(:x, :y)
18
+
19
+ pos1 = pos_builder.new(:x => 10, :y => 20)
20
+
21
+ pos1.to_hash.must_equal(:x => 10, :y => 20)
11
22
  end
12
23
 
13
24
  it "implements equality" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mozart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: