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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/light_record.rb +5 -6
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68b18b821e94f95075db330967d3cb14537ef4b3
4
- data.tar.gz: 6463993d97d10f007faee6c14fda80c2efad8c1e
3
+ metadata.gz: cea325f7a213deab5fa00bcf32d07ccd14456ba3
4
+ data.tar.gz: b5dd83b77f9929ee46b0dc8b9d02e78c526a2bb8
5
5
  SHA512:
6
- metadata.gz: fc8ebbe93aa163cfc93d1368f3cbfa6c90fa0893d9476336f908aea7f135c76e105515555b19226f2df6c856c3be86047625ad6a0039ebd4baa107d077fccbd4
7
- data.tar.gz: 4735d36300f2747a7233e728d05dcd143cd6103b361ded30293351c6754015744c7894609b68147c54d00b94b669fbe710501bcc9da6ceb1aeac948f2e41f78b
6
+ metadata.gz: 1ad5f7947d0570e46585d84882ce1e710973fbe43fa63aed576d0065b86918a77c08f9f9de4e8b27dddf69d3429bab58765b2e0893748eea84539dae91a92c36
7
+ data.tar.gz: 11231ea0c41e361b2247f6fe1816aa5a19bc1b48071447d9d78b7c3cbc3af787ab7928ef879b0615e2fe6677e223fec05f855f05135eb8bd9265792a4ee2d237
@@ -18,13 +18,12 @@ module LightRecord
18
18
  define_fields(fields)
19
19
 
20
20
  def initialize(data)
21
- @data = data
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
- @data[attr_name.to_sym]
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
- @data[field]
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
- @data[field] = value
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
- @data[self.class.primary_key.to_sym]
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.2'
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: 2015-10-03 00:00:00.000000000 Z
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: Getting process memory
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