not_yet_active_record 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 577dbe522e783155e0b1c388dac3dbe081df3f19
4
- data.tar.gz: 19aa7ad12071de04ca142d7315af07276512efe6
3
+ metadata.gz: 0ec85494c47d00e50cec3985b1151f3b03b17fe2
4
+ data.tar.gz: 1f34b172ccd9ed4bdadd35a6fba6387f9fc828bf
5
5
  SHA512:
6
- metadata.gz: 8079e68394054819f16cb2104cfc0695b95d260680a3960f06dea5373a6bd79e98dad94b863eb2229b7fc87ef1c07ce9b82f5af2520838a098f3461f9304be86
7
- data.tar.gz: c5d99b5965bd49095e5bba51fc1cb84e098ed370ee783b3dfb7cff79cb3aec004de551d1eb7577a519b119d107dd06df4488abd67acb22098d7f02f8d0e27a0b
6
+ metadata.gz: 65cead476572ff0208538270abe2d7fcde1f2ede2fff56fd929919807e5e5d97872023a7f630cf6bb77ac328995d306132a6544cfebba12ead17fdb722d79846
7
+ data.tar.gz: 83ecdbb345d2948deb8e3dad2cf80e9223f6861f4b67f2473709058c3b06817bb8ad7a19fcacd3e3e61928cb63eb9692fd19ec86db5937987183d8e27ba20a5a
data/README.md CHANGED
@@ -10,12 +10,13 @@ any later time to save into the database.
10
10
 
11
11
  gem install not_yet_active_record
12
12
 
13
- After installing the gem run
13
+ Next to create the UnsavedObject model and table.
14
14
 
15
15
  rails generate not_yet_active_record
16
16
  rake db:migrate
17
17
 
18
- to create the UnsavedObject model and table.
18
+ Rails will ask if you want to overwrite `unsaved_object.rb`. Confirm that you
19
+ do.
19
20
 
20
21
  ## Usage
21
22
 
@@ -1,3 +1,3 @@
1
1
  module NotYetActiveRecord
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -2,13 +2,11 @@ require "not_yet_active_record/version"
2
2
  require 'active_record'
3
3
 
4
4
  module NotYetActiveRecord
5
-
6
5
 
7
6
  module ClassMethods
8
7
  def not_yet_saved
9
- unsaved_array = []
10
- UnsavedObject.find_all_by_model_name(self.name).each do |unsaved|
11
- unsaved_array << unsaved.item
8
+ UnsavedObject.find_all_by_model_name(self.name).map do |unsaved|
9
+ unsaved.item
12
10
  end
13
11
  end
14
12
  end
data/spec/not_yet.sqlite3 CHANGED
Binary file
@@ -2,4 +2,14 @@ class Post < ActiveRecord::Base
2
2
  end
3
3
 
4
4
  class UnsavedObjects < ActiveRecord::Base
5
+ attr_accessible :model_name, :serialized_item
6
+
7
+ def item
8
+ return nil if not serialized_item
9
+ att_hash = YAML::load(serialized_item)
10
+ att_hash.delete("id")
11
+ att_hash.delete("created_at")
12
+ att_hash.delete("updated_at")
13
+ model_name.constantize.new(att_hash)
14
+ end
5
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: not_yet_active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Frey