massive_record 0.2.0.beta → 0.2.0.beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
- # v0.2.0 (git develop)
1
+ # v0.2.0.beta2 (git develop)
2
+
3
+ - We are now raising error if MassiveRecordClass.new(attributes) receives unknown attributes.
4
+ - Added support for Record.new(:references_many => [record, record]) and a_record.references_many = [record, record]
5
+
2
6
 
3
7
 
4
8
  # v0.2.0.beta (git master)
@@ -26,11 +30,13 @@
26
30
  - Simple implementation of references_one relation. This is where you have a foreign key you will look up in a different table.
27
31
 
28
32
 
33
+
29
34
  # v0.1.2
30
35
  - Fixed, or at least made better, the is_yaml? method in Wrapper::Cell.This functionality of serialize/de-serialize
31
36
  should be moved up into the ORM asap, but for now a hot fix has been applied.
32
37
 
33
38
 
39
+
34
40
  # v0.1.1
35
41
 
36
42
  - A ORM record now now if it is read only or not.
@@ -42,6 +48,7 @@
42
48
  - Bugfix: Database cleaner no longer tries to remove tables with same name twice.
43
49
 
44
50
 
51
+
45
52
  # v0.1.0
46
53
 
47
54
  - Communication with Hbase via Thrift.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- massive_record (0.2.0.beta)
4
+ massive_record (0.2.0.beta2)
5
5
  activemodel
6
6
  activesupport
7
7
  thrift (>= 0.5.0)
@@ -23,7 +23,7 @@ module MassiveRecord
23
23
  if respond_to? writer_method
24
24
  send(writer_method, value)
25
25
  else
26
- raise UnkownAttributeError.new("Unkown attribute: #{attr}")
26
+ raise UnknownAttributeError.new("Unkown attribute: #{attr}")
27
27
  end
28
28
  end
29
29
  end
@@ -112,9 +112,11 @@ module MassiveRecord
112
112
 
113
113
  attributes = {} if attributes.nil?
114
114
 
115
- self.attributes_raw = attributes_from_field_definition.merge(attributes)
115
+ self.attributes_raw = attributes_from_field_definition
116
116
  self.attributes = attributes
117
117
 
118
+ clear_dirty_states!
119
+
118
120
  _run_initialize_callbacks
119
121
  end
120
122
 
@@ -21,7 +21,7 @@ module MassiveRecord
21
21
  end
22
22
 
23
23
  # Raised if an attribute is unkown
24
- class UnkownAttributeError < MassiveRecordError
24
+ class UnknownAttributeError < MassiveRecordError
25
25
  end
26
26
 
27
27
  # Raised if id is missing when you try a save
@@ -134,6 +134,10 @@ module MassiveRecord
134
134
  relation_proxy(metadata.name)
135
135
  end
136
136
 
137
+ redefine_method(metadata.name+'=') do |records|
138
+ relation_proxy(metadata.name).replace(records)
139
+ end
140
+
137
141
  if metadata.persisting_foreign_key?
138
142
  add_field_to_column_family(metadata.store_in, metadata.foreign_key, :type => :array, :default => [])
139
143
  end
@@ -1,3 +1,3 @@
1
1
  module MassiveRecord
2
- VERSION = "0.2.0.beta"
2
+ VERSION = "0.2.0.beta2"
3
3
  end
@@ -45,7 +45,7 @@ describe "attribute methods" do
45
45
  end
46
46
 
47
47
  it "should raise an error if we encounter an unkown attribute" do
48
- lambda { @model.attributes = {:unkown => "foo"} }.should raise_error MassiveRecord::ORM::UnkownAttributeError
48
+ lambda { @model.attributes = {:unkown => "foo"} }.should raise_error MassiveRecord::ORM::UnknownAttributeError
49
49
  end
50
50
  end
51
51
  end
@@ -81,6 +81,10 @@ describe MassiveRecord::ORM::Base do
81
81
  model.foo.should == 'bar'
82
82
  end
83
83
 
84
+ it "should raise error if attribute is unknown" do
85
+ lambda { TestClass.new :unknown => 'attribute' }.should raise_error MassiveRecord::ORM::UnknownAttributeError
86
+ end
87
+
84
88
  it "should initialize an object via init_with()" do
85
89
  model = TestClass.allocate
86
90
  model.init_with 'attributes' => {:foo => 'bar'}
@@ -89,6 +89,12 @@ describe MassiveRecord::ORM::Relations::Interface do
89
89
  2.times { subject.boss }
90
90
  end
91
91
  end
92
+
93
+
94
+ it "should be assignable in initializer" do
95
+ person = Person.new :boss => boss
96
+ person.boss.should == boss
97
+ end
92
98
  end
93
99
  end
94
100
 
@@ -196,12 +202,23 @@ describe MassiveRecord::ORM::Relations::Interface do
196
202
  let(:proxy) { subject.send(:relation_proxy, "test_classes") }
197
203
 
198
204
  it { should respond_to :test_classes }
205
+ it { should respond_to :test_classes= }
199
206
  it { should respond_to :test_class_ids }
200
207
  it { should respond_to :test_class_ids= }
201
208
 
202
209
  it "should have an array as foreign_key attribute" do
203
210
  subject.test_class_ids.should be_instance_of Array
204
211
  end
212
+
213
+ it "should be assignable" do
214
+ subject.test_classes = [test_class]
215
+ subject.test_classes.should == [test_class]
216
+ end
217
+
218
+ it "should be assignable in initializer" do
219
+ person = Person.new :test_classes => [test_class]
220
+ person.test_classes.should == [test_class]
221
+ end
205
222
  end
206
223
  end
207
224
  end
@@ -151,16 +151,6 @@ describe "A table" do
151
151
  ActiveSupport::JSON.decode(row.values["misc:empty"]).class.should eql(Hash)
152
152
  end
153
153
 
154
- it "should display the previous value (versioning) of the column 'info:first_name'" do
155
- pending "should we implement this, Vincent? :-)"
156
-
157
- row = @table.first
158
- row.values["info:first_name"].should eql("Bob")
159
-
160
- prev_row = row.prev
161
- prev_row.values["info:first_name"].should eql("John")
162
- end
163
-
164
154
  it "should be able to perform partial updates" do
165
155
  row = @table.first(:select => ["misc"])
166
156
  row.update_columns({ :misc => { :genre => "M" } })
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 2
8
8
  - 0
9
- - beta
10
- version: 0.2.0.beta
9
+ - beta2
10
+ version: 0.2.0.beta2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Companybook