frozen_record 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/lib/frozen_record/base.rb +18 -1
- data/lib/frozen_record/version.rb +1 -1
- data/lib/frozen_record.rb +6 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/abstract_model.rb +3 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5477acbd4ee7ae0a0fcdfe48f71d323d00468780
|
4
|
+
data.tar.gz: 8d5eb8ed257ea8c244754c1e181b8cac7c3da91b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 766bd1bc51a4a3550cb1f0c393ebff069acea8f2315d969aa7ecd706792f1bc0e37a2796d01576aef597b540bf456889b60ae9bf45eff2081c06189f951116d7
|
7
|
+
data.tar.gz: ac701b3390eead9b097f7fa0a89aa2c8ef9bb1a2602dd4f2b97b20084b2d8c789e6645919bfe3df667be3444be76e963a263657c73eee50df480664abbabbe32
|
data/.travis.yml
CHANGED
data/lib/frozen_record/base.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'set'
|
2
|
+
require 'active_support/descendants_tracker'
|
2
3
|
|
3
4
|
module FrozenRecord
|
4
5
|
class Base
|
6
|
+
extend ActiveSupport::DescendantsTracker
|
5
7
|
extend ActiveModel::Naming
|
6
8
|
include ActiveModel::Conversion
|
7
9
|
include ActiveModel::AttributeMethods
|
@@ -42,6 +44,11 @@ module FrozenRecord
|
|
42
44
|
end
|
43
45
|
|
44
46
|
class << self
|
47
|
+
attr_accessor :abstract_class
|
48
|
+
|
49
|
+
def abstract_class?
|
50
|
+
defined?(@abstract_class) && @abstract_class
|
51
|
+
end
|
45
52
|
|
46
53
|
def current_scope
|
47
54
|
store[:scope] ||= Scope.new(self)
|
@@ -56,7 +63,7 @@ module FrozenRecord
|
|
56
63
|
:minimum, :maximum, :average, :sum, :count, to: :current_scope
|
57
64
|
|
58
65
|
def file_path
|
59
|
-
|
66
|
+
raise ArgumentError, "You must define `#{name}.base_path`" unless base_path
|
60
67
|
File.join(base_path, "#{name.underscore.pluralize}.yml")
|
61
68
|
end
|
62
69
|
|
@@ -67,6 +74,16 @@ module FrozenRecord
|
|
67
74
|
end
|
68
75
|
end
|
69
76
|
|
77
|
+
def eager_load!
|
78
|
+
if auto_reloading
|
79
|
+
raise RuntimeError, "There is no point eager loading a FrozenRecord if auto_reloading is enabled!"
|
80
|
+
end
|
81
|
+
|
82
|
+
return if abstract_class?
|
83
|
+
|
84
|
+
load_records
|
85
|
+
end
|
86
|
+
|
70
87
|
def load_records
|
71
88
|
if auto_reloading && file_changed?
|
72
89
|
@records = nil
|
data/lib/frozen_record.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -16,6 +16,8 @@ FrozenRecord::Base.base_path = File.join(File.dirname(__FILE__), 'fixtures')
|
|
16
16
|
|
17
17
|
Dir[File.expand_path(File.join(File.dirname(__FILE__), 'support', '**', '*.rb'))].each { |f| require f }
|
18
18
|
|
19
|
+
FrozenRecord.eager_load!
|
20
|
+
|
19
21
|
RSpec.configure do |config|
|
20
22
|
config.run_all_when_everything_filtered = true
|
21
23
|
config.filter_run :focus
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frozen_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean Boussier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- spec/frozen_record_spec.rb
|
119
119
|
- spec/scope_spec.rb
|
120
120
|
- spec/spec_helper.rb
|
121
|
+
- spec/support/abstract_model.rb
|
121
122
|
- spec/support/car.rb
|
122
123
|
- spec/support/country.rb
|
123
124
|
homepage: https://github.com/byroot/frozen_record
|
@@ -140,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
141
|
version: '0'
|
141
142
|
requirements: []
|
142
143
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.
|
144
|
+
rubygems_version: 2.5.1
|
144
145
|
signing_key:
|
145
146
|
specification_version: 4
|
146
147
|
summary: ActiveRecord like interface to read only access and query static YAML files
|
@@ -150,5 +151,6 @@ test_files:
|
|
150
151
|
- spec/frozen_record_spec.rb
|
151
152
|
- spec/scope_spec.rb
|
152
153
|
- spec/spec_helper.rb
|
154
|
+
- spec/support/abstract_model.rb
|
153
155
|
- spec/support/car.rb
|
154
156
|
- spec/support/country.rb
|