light_record 0.2 → 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 +4 -4
- data/lib/light_record.rb +5 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cea325f7a213deab5fa00bcf32d07ccd14456ba3
|
4
|
+
data.tar.gz: b5dd83b77f9929ee46b0dc8b9d02e78c526a2bb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ad5f7947d0570e46585d84882ce1e710973fbe43fa63aed576d0065b86918a77c08f9f9de4e8b27dddf69d3429bab58765b2e0893748eea84539dae91a92c36
|
7
|
+
data.tar.gz: 11231ea0c41e361b2247f6fe1816aa5a19bc1b48071447d9d78b7c3cbc3af787ab7928ef879b0615e2fe6677e223fec05f855f05135eb8bd9265792a4ee2d237
|
data/lib/light_record.rb
CHANGED
@@ -18,13 +18,12 @@ module LightRecord
|
|
18
18
|
define_fields(fields)
|
19
19
|
|
20
20
|
def initialize(data)
|
21
|
-
@
|
22
|
-
@attributes = @data
|
21
|
+
@attributes = data
|
23
22
|
@readonly = true
|
24
23
|
end
|
25
24
|
|
26
25
|
def read_attribute_before_type_cast(attr_name)
|
27
|
-
@
|
26
|
+
@attributes[attr_name.to_sym]
|
28
27
|
end
|
29
28
|
|
30
29
|
def self.subclass_from_attributes?(attrs)
|
@@ -78,19 +77,19 @@ module LightRecord
|
|
78
77
|
field = field.to_sym unless field.is_a?(Symbol)
|
79
78
|
@fields << field
|
80
79
|
define_method(field) do
|
81
|
-
@
|
80
|
+
@attributes[field]
|
82
81
|
end
|
83
82
|
|
84
83
|
# to avoid errors when try saving data
|
85
84
|
define_method("#{field}=") do |value|
|
86
|
-
@
|
85
|
+
@attributes[field] = value
|
87
86
|
end
|
88
87
|
end
|
89
88
|
|
90
89
|
# ActiveRecord make method :id refers to primary key, even there is no column "id"
|
91
90
|
if !fields.include?(:id) && !fields.include?("id") && primary_key.present?
|
92
91
|
define_method(:id) do
|
93
|
-
@
|
92
|
+
@attributes[self.class.primary_key.to_sym]
|
94
93
|
end
|
95
94
|
end
|
96
95
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: light_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Evstigneev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -44,7 +44,7 @@ rubyforge_project:
|
|
44
44
|
rubygems_version: 2.5.1
|
45
45
|
signing_key:
|
46
46
|
specification_version: 3
|
47
|
-
summary:
|
47
|
+
summary: ActiveRecord extension to speedup ActiveRecord object allocation
|
48
48
|
test_files:
|
49
49
|
- spec/light_record_spec.rb
|
50
50
|
- spec/prepare_db.rb
|