active_record_content_blob 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzUwMzA2MjM5MDY2YTRkMWEzNzk1NjJlNjQ4YjhlN2YxYzhjNmFmNQ==
4
+ NDdhNzkzYWRkMTk2YmM1MjFmZTBlNzE1NTYzNzgxZDMzZjhhNTM4ZQ==
5
5
  data.tar.gz: !binary |-
6
- NTdlYmZmYTU1YjAxNjgzOTk1OGM5ZGQ2NDE0Y2VmYTliYjZmN2VlOQ==
6
+ ZmIxY2U3MzI0MjMxNzdhNzhhNWMxODA0NTFmOTc0MDljMjA4M2FmZA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZTNhMWNlODNmOWQyYjQ0MTdiYjdmNjFkNDNlNmE0ZDg3OGY0NTVhNGYzYzQ1
10
- MzFlMWZhNTFmYmMwY2I4YWI0NjBiY2JiZTIwNWIwYTFlN2I4ZTUzMDU3ZWYx
11
- NjljYzYxOWMxMjUzODY3OTUwZTE5MWQ2Y2ZmZTU1OTc4MTFiMjU=
9
+ MWQ5ODRmMWJkOTFkMTQ1YzEzNjRiYTk4ZGUwNTVmODM0YWQ0ZDI4ZmI0YjM3
10
+ NWE2Yjc2NDFhNDI0ZWMwYzdiMmE4M2E0ODcyOTY1MTVjNDJmNjAzNTBhYzg0
11
+ Y2NhZDljMWYzMWVhOGU2MjU2YjBiMjkyNWQ0NmNkNjc2MzhhZDg=
12
12
  data.tar.gz: !binary |-
13
- MjQ5YTA1MjdhMzI4NzcxZDVjN2NjNmEwZWM1NDEwY2NlNmU5NDVhOWU4ZmY1
14
- M2FkODEyYWZlMmE1Mjc3MGNhOWRhN2ZhYWQ2ZTliNzA3YzNmNDJlODgzNDQ5
15
- N2FkOTBjY2E4NzBjNjIwODlkODVkZjlhYmU0OWI0OWY0ZmEyMWE=
13
+ ZjA5NzkxMmUyZGFiN2M3ODkwNDAwZTlmZDA1ZmJjMjkyYWM0MDYzZmRlYmU2
14
+ OWYxMjUxNDRhZTU2YjEwMzE0Zjc4N2JkZjFmZjFkNTVkYzY0MmQxYWE3Zjkx
15
+ MWM2MDU4MTY4ZTRmMGUwMjc3NzhhNjQ2ZDQ4YjlkYWM5Y2E1YWI=
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # ActiveRecordContentBlob
2
+
3
+ A convenience gem for associating serialized BLOBs with your records, if you happen to use blobs to store data that doesn't need to be scoped.
4
+
5
+ For example, when backing up Tweet data, a user may find it to have a `tweets` table containing fields such as `created_at`, so that they can query for all Tweets within a certain time period. But the other content that comes with a Tweet might be useful later, so it's convenient to stick the entire JSON representation of a Tweet into a BLOB.
6
+
7
+ But because ActiveRecord::Base will `select` all columns by default, querying across a large set of `tweets` will [slow performance](http://stackoverflow.com/questions/9511476/speed-of-mysql-query-on-tables-containing-blob-depends-on-filesystem-cache).
8
+
9
+
10
+ `ActiveRecordContentBlob` is simply a convenience gem that creates a polymorphic relationship between any other AR table.
11
+
12
+
13
+ **Note:** This is something I'm playing around with. I don't recommend it for production at this point.
14
+
15
+ ## Installation
16
+
17
+ gem install active_record_content_blob
18
+
19
+
20
+ Include it in your `Gemfile`
21
+
22
+ bundle install
23
+
24
+ Run the `rake` task to modify your database
25
+
26
+ rails generate content_blob
27
+ rake db:migrate
28
+
29
+ Sample usage:
30
+
31
+ record = MusicRecord.new
32
+ record.build_a_blob({'title' => "The Jackson 5"})
33
+ record.save
34
+
35
+ record.contents['title']
36
+ # => The Jackson 5
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "active_record_content_blob"
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dan Nguyen"]
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.email = "dansonguyen@gmail.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
- "README.rdoc"
17
+ "README.md"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  "Gemfile",
23
23
  "Gemfile.lock",
24
24
  "LICENSE.txt",
25
- "README.rdoc",
25
+ "README.md",
26
26
  "Rakefile",
27
27
  "VERSION",
28
28
  "active_record_content_blob.gemspec",
data/lib/content_blob.rb CHANGED
@@ -2,7 +2,7 @@ require 'active_record'
2
2
  require 'active_support'
3
3
  class ContentBlob < ActiveRecord::Base
4
4
 
5
-
5
+ attr_accessible :contents
6
6
  serialize :contents
7
7
 
8
8
  validates_uniqueness_of :blobable_id, scope: :blobable_type
@@ -9,8 +9,6 @@ class BadRecord < ActiveRecord::Base; end
9
9
  describe "Blobable" do
10
10
  before(:each) do
11
11
  DatabaseCleaner.clean
12
- MusicRecord.delete_all
13
- ContentBlob.delete_all
14
12
  end
15
13
 
16
14
  it 'should raise an error if a class has :contents as an actual field' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_content_blob
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Nguyen
@@ -128,14 +128,14 @@ executables: []
128
128
  extensions: []
129
129
  extra_rdoc_files:
130
130
  - LICENSE.txt
131
- - README.rdoc
131
+ - README.md
132
132
  files:
133
133
  - .document
134
134
  - .rspec
135
135
  - Gemfile
136
136
  - Gemfile.lock
137
137
  - LICENSE.txt
138
- - README.rdoc
138
+ - README.md
139
139
  - Rakefile
140
140
  - VERSION
141
141
  - active_record_content_blob.gemspec
data/README.rdoc DELETED
@@ -1,19 +0,0 @@
1
- = active_record_content_blob
2
-
3
- Description goes here.
4
-
5
- == Contributing to active_record_content_blob
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
- * Fork the project.
10
- * Start a feature/bugfix branch.
11
- * Commit and push until you are happy with your contribution.
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2013 Dan Nguyen. See LICENSE.txt for
18
- further details.
19
-