not_yet_active_record 0.0.1 → 0.0.2
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 +4 -4
- data/lib/generators/not_yet_active_record/not_yet_active_record_generator.rb +3 -10
- data/lib/generators/not_yet_active_record/templates/unsaved_object.rb +10 -1
- data/lib/not_yet_active_record/version.rb +1 -1
- data/lib/not_yet_active_record.rb +0 -9
- metadata +1 -2
- data/lib/generators/not_yet_active_record/templates/schema.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 577dbe522e783155e0b1c388dac3dbe081df3f19
|
4
|
+
data.tar.gz: 19aa7ad12071de04ca142d7315af07276512efe6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
17
|
-
|
18
|
-
|
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 :
|
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
|
@@ -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.
|
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
|