rails_metadata 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -2
- data/lib/rails_metadata/version.rb +1 -1
- data/lib/rails_metadata.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d70c4718bb870c6bd0de9799148db4d1792afc0
|
4
|
+
data.tar.gz: dfb7b2903774eb0c64e12c6331a51dc0099f2f81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca7741953af6e127e6925831a5136b205cd6ccf093cc4a77d534bcd6112f62bdc30f1d2c27ed11c61c0d2644b583fa364ac558d5631dbf54e75a7a1647f1defd
|
7
|
+
data.tar.gz: fcd9ba1a7ee8e0a0656757b6d60485bc147d3b9eaac52ae6e70f5e0d5794a3083060343e0f8fe9f3a5d3143b1485efe76f888dbad03fadb7bf6f51648a57d7b1
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# RailsMetadata
|
2
2
|
|
3
|
-
|
3
|
+
For adding fake fields stored in a hash in Rails.
|
4
|
+
|
5
|
+
More documentation to come when I'm less lazy.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -18,7 +20,18 @@ Or install it yourself as:
|
|
18
20
|
|
19
21
|
## Usage
|
20
22
|
|
21
|
-
|
23
|
+
For any model you want to use this on, add the following.
|
24
|
+
```
|
25
|
+
include RailsMetadata
|
26
|
+
serializable :metadata, Hash
|
27
|
+
```
|
28
|
+
And perform the following migration
|
29
|
+
```
|
30
|
+
add_column :table_name, :metadata, :text
|
31
|
+
```
|
32
|
+
|
33
|
+
The default limit on :text fields is 65535, so if you anticipate storing more
|
34
|
+
than that, you should set the limit higher on the column.
|
22
35
|
|
23
36
|
## Contributing
|
24
37
|
|
data/lib/rails_metadata.rb
CHANGED
@@ -13,7 +13,7 @@ module RailsMetadata
|
|
13
13
|
end
|
14
14
|
typecast = case type
|
15
15
|
when nil then val
|
16
|
-
when :boolean then lambda { |v| v.is_a?(String) ? v.empty? : !!v }
|
16
|
+
when :boolean then lambda { |v| v.is_a?(String) ? !v.empty? : !!v }
|
17
17
|
when :string then lambda { |v| v.to_s }
|
18
18
|
when :integer then lambda { |v| v.to_i }
|
19
19
|
when :float then lambda { |v| v.to_f }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_metadata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Neyer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|