not_yet_active_record 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f6af89a34d5534b2850ce6e25561e78df512b965
4
- data.tar.gz: 4a37ed76f037d9641e46d8260cc36184ee2df4b5
3
+ metadata.gz: 577dbe522e783155e0b1c388dac3dbe081df3f19
4
+ data.tar.gz: 19aa7ad12071de04ca142d7315af07276512efe6
5
5
  SHA512:
6
- metadata.gz: 61039c5655ce6699f76d67887c8f2fa420836cbb6adbb50fe2fb21152758703df766185e63f61d5e875db0ae72d303e4d868ed2f0ea20bd46b650ebabdb18afc
7
- data.tar.gz: 1042b1a0bdedaa41134563500531161fb6f1f27861c468a5312c53455614575fdba0adfe21bf176e1be20c10d8769bfa9fc1bb7fd52e214ba1f5a974837656cd
6
+ metadata.gz: 8079e68394054819f16cb2104cfc0695b95d260680a3960f06dea5373a6bd79e98dad94b863eb2229b7fc87ef1c07ce9b82f5af2520838a098f3461f9304be86
7
+ data.tar.gz: c5d99b5965bd49095e5bba51fc1cb84e098ed370ee783b3dfb7cff79cb3aec004de551d1eb7577a519b119d107dd06df4488abd67acb22098d7f02f8d0e27a0b
@@ -13,15 +13,8 @@ module NotYetActiveRecord
13
13
  generate "model UnsavedObject serialized_item:text model_name:string"
14
14
  end
15
15
 
16
- # def create_migration_file
17
- # copy_file 'schema.rb',
18
- # "db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_unsaved_objects.rb"
19
- # end
20
-
21
- # def create_model
22
- # copy_file 'unsaved_object.rb', "app/models/unsaved_object.rb"
23
- # end
24
-
25
-
16
+ def add_method
17
+ copy_file "unsaved_object.rb", "app/models/unsaved_object.rb"
18
+ end
26
19
  end
27
20
  end
@@ -1,3 +1,12 @@
1
1
  class UnsavedObject < ActiveRecord::Base
2
- attr_accessible :serialized_item, :model_name
2
+ attr_accessible :model_name, :serialized_item
3
+
4
+ def item
5
+ return nil if not serialized_item
6
+ att_hash = YAML::load(serialized_item)
7
+ att_hash.delete("id")
8
+ att_hash.delete("created_at")
9
+ att_hash.delete("updated_at")
10
+ model_name.constantize.new(att_hash)
11
+ end
3
12
  end
@@ -1,3 +1,3 @@
1
1
  module NotYetActiveRecord
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -34,12 +34,3 @@ class ActiveRecord::Base
34
34
  include NotYetActiveRecord
35
35
  end
36
36
 
37
- class UnsavedObject < ActiveRecord::Base
38
- def item
39
- att_hash = YAML::load(serialized_item)
40
- att_hash.delete("id")
41
- att_hash.delete("created_at")
42
- att_hash.delete("updated_at")
43
- model_name.constantize.new(att_hash)
44
- end
45
- 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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Frey
@@ -107,7 +107,6 @@ files:
107
107
  - README.md
108
108
  - Rakefile
109
109
  - lib/generators/not_yet_active_record/not_yet_active_record_generator.rb
110
- - lib/generators/not_yet_active_record/templates/schema.rb
111
110
  - lib/generators/not_yet_active_record/templates/unsaved_object.rb
112
111
  - lib/not_yet_active_record.rb
113
112
  - lib/not_yet_active_record/version.rb
@@ -1,14 +0,0 @@
1
- class CreateNotYetActiveRecords < ActiveRecord::Migration
2
- def up
3
- create_table :not_yet_active_records do |t|
4
- t.text :serialized_item
5
- t.string :model_name
6
-
7
- t.timestamps
8
- end
9
- end
10
-
11
- def down
12
- drop_table :not_yet_active_records
13
- end
14
- end