yaml-model 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -155,6 +155,12 @@ class YAML_Model
155
155
  "#{self.class.name}[#{id}]"
156
156
  end
157
157
 
158
+ def inspect
159
+ keys = self.class.attributes.keys.sort
160
+ keys.delete( :id )
161
+ "#{to_s}{#{keys.map{|k|"#{k.inspect}=>#{self.send(k).inspect}"}.join(',')}}"
162
+ end
163
+
158
164
  def self.sort_by( *attributes )
159
165
  define_method '<=>'.to_sym do |other|
160
166
  attributes.map{|a|self.send(a)} <=> attributes.map{|a|other.send(a)}
@@ -1,3 +1,3 @@
1
1
  class YAML_Model
2
- VERSION = "1.3.2"
2
+ VERSION = "1.3.3"
3
3
  end
@@ -0,0 +1,25 @@
1
+ require 'yaml-model'
2
+
3
+ describe YAML_Model, ".to_s" do
4
+
5
+ InspectedModelReference = Class.new( YAML_Model )
6
+
7
+ class InspectedModel < YAML_Model
8
+ type :name, String
9
+ type :at, Time
10
+ type :reference, InspectedModelReference
11
+ init :name, :at, :reference
12
+ end
13
+
14
+ before( :each ) do
15
+ YAML_Model.reset!
16
+ end
17
+
18
+ it "Inspects with the correct information" do
19
+ next_oid = YAML_Model.next_oid
20
+ ref = InspectedModelReference.create
21
+ at = Time.now
22
+ InspectedModel.create( 'foo', at, ref ).inspect.should == "InspectedModel[#{next_oid+1}]{:at=>#{at.inspect},:name=>\"foo\",:reference=>InspectedModelReference[#{next_oid}]{}}"
23
+ end
24
+
25
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 3
8
- - 2
9
- version: 1.3.2
8
+ - 3
9
+ version: 1.3.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Clive Crous
@@ -81,6 +81,7 @@ files:
81
81
  - test/delete.rb
82
82
  - test/has.rb
83
83
  - test/init.rb
84
+ - test/inspect.rb
84
85
  - test/to_s.rb
85
86
  - test/type.rb
86
87
  - yaml-model.gemspec
@@ -98,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
99
  requirements:
99
100
  - - ">="
100
101
  - !ruby/object:Gem::Version
101
- hash: -230929969
102
+ hash: 491835281
102
103
  segments:
103
104
  - 0
104
105
  version: "0"
@@ -107,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
108
  requirements:
108
109
  - - ">="
109
110
  - !ruby/object:Gem::Version
110
- hash: -230929969
111
+ hash: 491835281
111
112
  segments:
112
113
  - 0
113
114
  version: "0"