lazy_record 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lazy_record/associations.rb +2 -2
- data/lib/lazy_record/relation.rb +3 -2
- data/lib/lazy_record/version.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: 2e410789bff0ade6d3e280351d33ce2f71faea53
|
4
|
+
data.tar.gz: 2ea69bd06cd78bb8416e41d1146efbc21c26c690
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b398f283d8a00b40dbf3bd86bc9d3a8bd6858f5a56073628d67195b94c4fcfec24717cd681f92b9bb0074eaaebbfb70b70664e692b38f910f7cd8e4ec1b8a2f
|
7
|
+
data.tar.gz: 5f9b063541789a1efaf285f9729b76130283946aecdb188aabc540d04964f1fff44f35b01738abe2f8590ce5072a8a8808529157d89c9136fe6a82d2be8d5ad9
|
@@ -7,7 +7,7 @@ module LazyRecord
|
|
7
7
|
NESTED_ATTRS_MODULE_NAME = :NestedAttributes
|
8
8
|
|
9
9
|
def define_collection_getter(collection, class_name)
|
10
|
-
model = apply_nesting(class_name).constantize
|
10
|
+
model = -> { apply_nesting(class_name).constantize }
|
11
11
|
define_method(collection) do
|
12
12
|
if instance_variable_get("@#{collection}").nil?
|
13
13
|
instance_variable_set("@#{collection}", Relation.new(model: model))
|
@@ -17,7 +17,7 @@ module LazyRecord
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def define_collection_setter(collection, class_name)
|
20
|
-
model = apply_nesting(class_name).constantize
|
20
|
+
model = -> { apply_nesting(class_name).constantize }
|
21
21
|
define_method("#{collection}=") do |coll|
|
22
22
|
coll = Relation.new(model: model, array: coll) if coll.is_a?(Array)
|
23
23
|
return instance_variable_set("@#{collection}", coll) if coll.is_a? Relation
|
data/lib/lazy_record/relation.rb
CHANGED
@@ -7,6 +7,7 @@ module LazyRecord
|
|
7
7
|
attr_reader :model, :all
|
8
8
|
|
9
9
|
def initialize(model:, array: nil)
|
10
|
+
model = model.call if model.is_a? Proc
|
10
11
|
raise ArgumentError, 'model must be a class' unless model.is_a?(Class)
|
11
12
|
@model = model
|
12
13
|
@all = []
|
@@ -63,8 +64,8 @@ module LazyRecord
|
|
63
64
|
private :clear, :all
|
64
65
|
|
65
66
|
def self_extend_scopes_module
|
66
|
-
return unless model.const_defined?(
|
67
|
-
extend(model::
|
67
|
+
return unless model.const_defined?(Scopes::SCOPE_MODULE_NAME, _search_ancestors = false)
|
68
|
+
extend(model.const_get(Scopes::SCOPE_MODULE_NAME))
|
68
69
|
end
|
69
70
|
end
|
70
71
|
end
|
data/lib/lazy_record/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lazy_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- M. Simon Borg
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|