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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f4aa0f0eb8e4f1d0177ff328886762f34f2ca6b7be2f29be6e6d81b7082f932
4
- data.tar.gz: 4ba6ae82c5276b0a594203faeb37d3bc66db87815b8c79ec042fae424f9ac3aa
3
+ metadata.gz: 37b0f8692505a8c0eb8e1410f1421139f9247a5302ef839e092a38e1aef44a51
4
+ data.tar.gz: 4acbd231917862f721aa9e94cf2bed96ac87c0ab31a1a51cf6e2bbe8b42ef173
5
5
  SHA512:
6
- metadata.gz: 248ff7b584f16b6c29e8238dcd32fe610317ecd3f58d5ad659ff7753f8d6bc7cd1caeb67c94385c5270592f73f36de32da82d5399b7f6690c215390455944537
7
- data.tar.gz: b20a1ba4f587ad84b407c447ba3cd978910b068141fa4337e0e81919b76780b73a79e7bdb290cc83d80a66b2183c3a58325da8758703c7e34d18d8819f3cb58c
6
+ metadata.gz: 7d82f0494a4a1157b203d35a5dd7e5db0bc0987d813ead7c28eb7f399ef1c4a9f44cbf4909db7f8c2e647cb3352e231a8c309f80a8dec8434780f0c6c5af1081
7
+ data.tar.gz: efb282c26b87a863cc09021f266924a0a2ac7544f39af116d4b1a75cd3f4667d6f17916b0c89e7c1bd26cdd22bb1d1bbbdb49bae01c3640bbb2f12e1bc68d1b3
@@ -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
- "Attribute was supposed to be a #{object_class}, but was a #{obj.class}"
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.tap do |reflection|
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.1
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: 2019-11-08 00:00:00.000000000 Z
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.5'
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.0.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