reactive-record 0.7.38 → 0.7.39
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38627e5aff47130857117db10b665d62df420ddd
|
4
|
+
data.tar.gz: d5f8d93a888c7ac27a7032f020ca784553b1dceb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11dcbafdbb5d8bc1d9c00586c38ea6bb15726d6045ab18a75ff622f087c18c76755899dce2fe6e5a2f5cf424d3b05e23b73b8beb3a4127a07b3782a1e1f4e9b3
|
7
|
+
data.tar.gz: 47c7b2bf0db583da4940395dbe9c3fc476892bebd04697335a9a38a9a6b1e6c0b3eb9f93447e5020b18acf66db88707a928803bcc1b7faa1126973ae152b3923
|
data/lib/reactive-record.rb
CHANGED
@@ -16,27 +16,6 @@ if RUBY_ENGINE == 'opal'
|
|
16
16
|
|
17
17
|
else
|
18
18
|
|
19
|
-
module ::ActiveRecord
|
20
|
-
module Core
|
21
|
-
module ClassMethods
|
22
|
-
def inherited(child_class)
|
23
|
-
begin
|
24
|
-
file = Rails.root.join('app','models',"#{child_class.name.underscore}.rb").to_s rescue nil
|
25
|
-
begin
|
26
|
-
require file
|
27
|
-
rescue LoadError
|
28
|
-
end
|
29
|
-
# from active record:
|
30
|
-
child_class.initialize_find_by_cache
|
31
|
-
rescue
|
32
|
-
end
|
33
|
-
super
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
19
|
require "opal"
|
41
20
|
require "reactive_record/version"
|
42
21
|
require "reactive_record/permissions"
|
@@ -49,6 +49,10 @@ module ActiveRecord
|
|
49
49
|
base_class.instance_eval {ReactiveRecord::Base.find(self, opts.first.first, opts.first.last)}
|
50
50
|
end
|
51
51
|
|
52
|
+
def enum(*args)
|
53
|
+
# when we implement schema validation we should also implement value checking
|
54
|
+
end
|
55
|
+
|
52
56
|
def method_missing(name, *args, &block)
|
53
57
|
if args.count == 1 && name =~ /^find_by_/ && !block
|
54
58
|
find_by(name.gsub(/^find_by_/, "") => args[0])
|
@@ -370,6 +370,10 @@ module ReactiveRecord
|
|
370
370
|
end
|
371
371
|
end
|
372
372
|
|
373
|
+
def self.is_enum?(record, key)
|
374
|
+
record.class.respond_to?(:defined_enums) && record.class.defined_enums[key]
|
375
|
+
end
|
376
|
+
|
373
377
|
def self.save_records(models, associations, acting_user, validate, save)
|
374
378
|
reactive_records = {}
|
375
379
|
vectors = {}
|
@@ -394,7 +398,9 @@ module ReactiveRecord
|
|
394
398
|
# we have an already exising activerecord model
|
395
399
|
keys = record.attributes.keys
|
396
400
|
attributes.each do |key, value|
|
397
|
-
if
|
401
|
+
if is_enum?(record, key)
|
402
|
+
record.send("#{key}=",value)
|
403
|
+
elsif keys.include? key
|
398
404
|
record[key] = value
|
399
405
|
elsif !value.nil? and aggregation = record.class.reflect_on_aggregation(key.to_sym) and !(aggregation.klass < ActiveRecord::Base)
|
400
406
|
aggregation.mapping.each_with_index do |pair, i|
|
@@ -411,7 +417,9 @@ module ReactiveRecord
|
|
411
417
|
dont_save_list << record unless save
|
412
418
|
keys = record.attributes.keys
|
413
419
|
attributes.each do |key, value|
|
414
|
-
if
|
420
|
+
if is_enum?(record, key)
|
421
|
+
record.send("#{key}=",value)
|
422
|
+
elsif keys.include? key
|
415
423
|
record[key] = value
|
416
424
|
elsif !value.nil? and aggregation = record.class.reflect_on_aggregation(key) and !(aggregation.klass < ActiveRecord::Base)
|
417
425
|
aggregation.mapping.each_with_index do |pair, i|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reactive-record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.39
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mitch VanDuyn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|