bsm-models 0.12.1 → 0.12.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bsm/model/abstract.rb +3 -3
- data/lib/bsm/model/coders/abstract_column.rb +2 -4
- data/lib/bsm/model/coders/json_column.rb +0 -2
- data/lib/bsm/model/coders/marshal_column.rb +0 -2
- data/lib/bsm/model/has_many_serialized.rb +2 -5
- data/lib/bsm/model/sti_convertable.rb +5 -4
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37b0f8692505a8c0eb8e1410f1421139f9247a5302ef839e092a38e1aef44a51
|
4
|
+
data.tar.gz: 4acbd231917862f721aa9e94cf2bed96ac87c0ab31a1a51cf6e2bbe8b42ef173
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d82f0494a4a1157b203d35a5dd7e5db0bc0987d813ead7c28eb7f399ef1c4a9f44cbf4909db7f8c2e647cb3352e231a8c309f80a8dec8434780f0c6c5af1081
|
7
|
+
data.tar.gz: efb282c26b87a863cc09021f266924a0a2ac7544f39af116d4b1a75cd3f4667d6f17916b0c89e7c1bd26cdd22bb1d1bbbdb49bae01c3640bbb2f12e1bc68d1b3
|
data/lib/bsm/model/abstract.rb
CHANGED
@@ -9,9 +9,9 @@ module Bsm::Model::Abstract
|
|
9
9
|
end
|
10
10
|
|
11
11
|
class_eval <<-METHOD, __FILE__, __LINE__ + 1
|
12
|
-
def abstract_model_instance?
|
13
|
-
self.class >= ::#{name}
|
14
|
-
end
|
12
|
+
def abstract_model_instance? # def abstract_model_instance?
|
13
|
+
self.class >= ::#{name} # self.class >= ::ThisModel
|
14
|
+
end # end
|
15
15
|
METHOD
|
16
16
|
|
17
17
|
protected :must_not_be_abstract, :abstract_model_instance?
|
@@ -1,5 +1,4 @@
|
|
1
1
|
class Bsm::Model::Coders::AbstractColumn
|
2
|
-
|
3
2
|
def self.rescue_errors
|
4
3
|
[]
|
5
4
|
end
|
@@ -8,7 +7,7 @@ class Bsm::Model::Coders::AbstractColumn
|
|
8
7
|
attr_reader :object_class
|
9
8
|
|
10
9
|
# @param [Class] obejct_class
|
11
|
-
def initialize(object_class=Object)
|
10
|
+
def initialize(object_class = Object)
|
12
11
|
@object_class = object_class
|
13
12
|
end
|
14
13
|
|
@@ -24,7 +23,7 @@ class Bsm::Model::Coders::AbstractColumn
|
|
24
23
|
|
25
24
|
unless obj.is_a?(object_class) || obj.nil?
|
26
25
|
raise ActiveRecord::SerializationTypeMismatch,
|
27
|
-
|
26
|
+
"Attribute was supposed to be a #{object_class}, but was a #{obj.class}"
|
28
27
|
end
|
29
28
|
obj ||= object_class.new if object_class != Object
|
30
29
|
|
@@ -39,5 +38,4 @@ class Bsm::Model::Coders::AbstractColumn
|
|
39
38
|
def _load(_string)
|
40
39
|
raise NotImplementedError
|
41
40
|
end
|
42
|
-
|
43
41
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
class Bsm::Model::Coders::JsonColumn < Bsm::Model::Coders::AbstractColumn
|
2
|
-
|
3
2
|
def self.rescue_errors
|
4
3
|
[::JSON::ParserError]
|
5
4
|
end
|
@@ -13,5 +12,4 @@ class Bsm::Model::Coders::JsonColumn < Bsm::Model::Coders::AbstractColumn
|
|
13
12
|
def _load(string)
|
14
13
|
ActiveSupport::JSON.decode(string)
|
15
14
|
end
|
16
|
-
|
17
15
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'base64'
|
2
2
|
|
3
3
|
class Bsm::Model::Coders::MarshalColumn < Bsm::Model::Coders::AbstractColumn
|
4
|
-
|
5
4
|
def self.rescue_errors
|
6
5
|
[ArgumentError, TypeError]
|
7
6
|
end
|
@@ -15,5 +14,4 @@ class Bsm::Model::Coders::MarshalColumn < Bsm::Model::Coders::AbstractColumn
|
|
15
14
|
def _load(string)
|
16
15
|
Marshal.load(Base64.decode64(string))
|
17
16
|
end
|
18
|
-
|
19
17
|
end
|
@@ -4,17 +4,15 @@ module Bsm::Model::HasManySerialized
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
module ClassMethods
|
7
|
-
def has_many_serialized(name, scope=nil, options={})
|
7
|
+
def has_many_serialized(name, scope = nil, options = {})
|
8
8
|
Builder.build(self, name, scope, options)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
class Builder < ActiveRecord::Associations::Builder::CollectionAssociation
|
13
|
-
|
14
13
|
def self.build(model, name, *)
|
15
14
|
model.serialize "#{name.to_s.singularize}_ids", ::Bsm::Model::Coders::JsonColumn.new(Array)
|
16
|
-
super
|
17
|
-
end
|
15
|
+
super
|
18
16
|
end
|
19
17
|
|
20
18
|
def self.define_accessors(model, reflection)
|
@@ -49,6 +47,5 @@ module Bsm::Model::HasManySerialized
|
|
49
47
|
def valid_dependent_options
|
50
48
|
[]
|
51
49
|
end
|
52
|
-
|
53
50
|
end
|
54
51
|
end
|
@@ -3,10 +3,11 @@ module Bsm::Model::StiConvertable
|
|
3
3
|
|
4
4
|
included do
|
5
5
|
include Bsm::Model::EagerDescendants
|
6
|
+
|
6
7
|
class_eval <<-METHOD, __FILE__, __LINE__ + 1
|
7
|
-
def self.real_type?
|
8
|
-
self < ::#{name}
|
9
|
-
end
|
8
|
+
def self.real_type? # def real_type?
|
9
|
+
self < ::#{name} # self.class < ::ThisModel
|
10
|
+
end # end
|
10
11
|
METHOD
|
11
12
|
end
|
12
13
|
|
@@ -16,7 +17,7 @@ module Bsm::Model::StiConvertable
|
|
16
17
|
|
17
18
|
module ClassMethods
|
18
19
|
# @Override: Allow to specify a kind
|
19
|
-
def new(attributes=nil, *args, &block)
|
20
|
+
def new(attributes = nil, *args, &block)
|
20
21
|
kind = attributes.delete(:kind) { attributes.delete('kind') } if attributes.respond_to?(:delete)
|
21
22
|
return super if real_type?
|
22
23
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bsm-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitrij Denissenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: rubocop
|
70
|
+
name: rubocop-bsm
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -139,14 +139,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
139
139
|
requirements:
|
140
140
|
- - ">="
|
141
141
|
- !ruby/object:Gem::Version
|
142
|
-
version: '2.
|
142
|
+
version: '2.6'
|
143
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
144
|
requirements:
|
145
145
|
- - ">="
|
146
146
|
- !ruby/object:Gem::Version
|
147
147
|
version: '0'
|
148
148
|
requirements: []
|
149
|
-
rubygems_version: 3.
|
149
|
+
rubygems_version: 3.1.4
|
150
150
|
signing_key:
|
151
151
|
specification_version: 4
|
152
152
|
summary: BSM's very custom model extensions
|