lazy_record 0.2.0 → 0.2.1

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: 02e7026ed898c508dbf1d414caa9a49d46fc768b
4
- data.tar.gz: d47a262f3619021a1bb2fc0441fe3ece573bca78
3
+ metadata.gz: 2e410789bff0ade6d3e280351d33ce2f71faea53
4
+ data.tar.gz: 2ea69bd06cd78bb8416e41d1146efbc21c26c690
5
5
  SHA512:
6
- metadata.gz: 8d02068fc6418b585f478f0b70260da72849d8945510a0724d9847376a9ec2ec5ec149c9566d76b776b52650124acf1177a61e81278f8d830750e9f8245085ef
7
- data.tar.gz: 50f028b5d8c2cf45130a9d58b702cd4aad0c0d31eeb3fe1f91817d7a4a595cb6c4dd5304c369858c50e31a9b44d645dad745d37c5173ad6b9949b7b8d9bbd035
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
@@ -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?(:ScopeMethods, _search_ancestors = false)
67
- extend(model::ScopeMethods)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LazyRecord
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
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.0
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-07 00:00:00.000000000 Z
11
+ date: 2017-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport